Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Userscript Fix #146

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Userscript Fix #146

wants to merge 4 commits into from

Conversation

trapgod1
Copy link

No description provided.

@gambergeurr
Copy link

thank you (firefox v133.0.3 64 bits)

const originalAppendChild = document.head.appendChild;

document.head.appendChild = function (element) {
if (element.tagName === "SCRIPT") {
if (element.src.includes("player-core-variant-a")) {
if (element.src && element.src.includes("player-core-variant-a")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (element.src && element.src.includes("player-core-variant-a")) {
if (element?.src?.includes("player-core-variant-a")) {

// @grant none
// ==/UserScript==

(function () {
'use strict';

var isVariantA = false;

const originalAppendChild = document.head.appendChild;

document.head.appendChild = function (element) {
if (element.tagName === "SCRIPT") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (element.tagName === "SCRIPT") {
if (element?.tagName === "SCRIPT") {

Copy link

@BlueWorld1 BlueWorld1 Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion just for consistency, probably sure it's not needed (an element with no tag name does not make any sense).


if (!isVariantA) {
this.addEventListener("message", (event) => {
const data = event.data;

if (data.id == 1 && data.type == 1) {
const newData = event.data;

const newData = { ...data };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really needed to use the spread operator here ? why const newData = event.data; does not work ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const newData = { ...data }; avoids changing the original data.
const newData = event.data; is causing Error #4000, Issue #144

@Randomire44
Copy link

It works only if I re-add // @run-at document-start. Any reason why you removed it ?

@sn-o-w
Copy link

sn-o-w commented Jan 3, 2025

@trapgod1 I use Violentmonkey and there is a scenario in which the script will not work.

  • Open in a new tab a Twitch channel you know has sub only VODs.
  • Afterwards manually click on a sub only VOD.
  • Notice the script is not injected because the initial URL didn't have "/video/" or "/videos/" in the URL.

🤔

@kioshimushi
Copy link

Tested your bug fixes (1.0.4) and it still doesn't work if // @run-at document-start is not added as @Randomire44 mentioned.

@trapgod1
Copy link
Author

trapgod1 commented Jan 3, 2025

Tested your bug fixes (1.0.4) and it still doesn't work if // @run-at document-start is not added as @Randomire44 mentioned.

whats browser are you using ?
tested on chrome and firefox with Violet Monkey

Edit: TamperMonkey Permission issue

Edit 2: New version should of fixed the issue

@kioshimushi
Copy link

Tested your bug fixes (1.0.4) and it still doesn't work if // @run-at document-start is not added as @Randomire44 mentioned.

whats browser are you using ? tested on chrome and firefox with Violet Monkey

Edit: TamperMonkey Permission issue

Edit 2: New version should of fixed the issue

Yes I was using TamperMonkey on Firefox.

Just tested 1.0.5, seems to load fine this time!

@Randomire44
Copy link

Just tested 1.0.5, no problems at all. Thank you so much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants