I made a short script that makes that removes the 'play on tv' button on youtube, and the script itself works totally fine.
The problem is that the script doesn't even run at all when I start on youtube's homepage. And because of how youtube runs, when you click on a video, it continues to not run the script at all. But if I then refresh on the video page, the script starts running fine, even if I go back to the homepage then onto a video again(as long as it is the same tab). But then it will also stop working again if I refresh on the homepage. It also works totally fine when if I open a new tab on youtube directly onto a video. It just doesn't run when a new session of youtube is started on a tab specifically on the homepage.
I tried using these:
#match https://www.youtube.com/*
#include https://www.youtube.com
But the script still does not run at all.
I started to think this may be a bug on TamperMonkey's side because it isn't even only my script that seems to have this issue. I have one more script that runs on youtube, Youtube Auto-Translate Canceler, that also seems to be running into this issue as well.
It is also bizzare that when you load onto the youtube homepage, TamperMonkey on the extension bar seems to show that there are 2 scripts running for a split second before it disappears and shows 'no scripts is running'.
As I was writing this, I tested these out:
#match https://*
#match https://*/*
And it still didn't work only for youtube's homepage.
I did see this other question that is maybe running into a similar situation, but I'm not too sure if this is the same problem, because to me it seems like if this is the case then it should not work for all of youtube, not just the homepage.
So I am now pretty convinced that this is a most likely a bug. But I do want to know if anyone knows any kind of work arounds if there are any. It may also have to do with google chrome specifically, but I'm not sure.
Thank you.
Related
I have a super simple script (running in a Userscript manager for Safari) that works on some pages but not all.
Here is the script:
// ==UserScript==
// #name Close tab on double click
// #include https://*
// ==/UserScript==
document.addEventListener("dblclick",function (event) {
window.close();
});
For some reason, it works on Stack Overflow, Reddit post pages, etc., but does NOT work on Reddit homepage, Google (homepage or search results), etc.
Why?
Thanks for any insight. I'm still a newbie about javascript.
Edit: Working now, using the GM.closeTab permission from my Userscript manager, as documented here: https://github.com/quoid/userscripts#api
Try using
// #grant window.close
in order to use window.close per the documentation.
In a chrome browser, when I add the JS function in the console and then double click on the page I get this notification (I tried the stack overflow site):
Console Image
My guess is your userscript manager may add the script you write differently depending on the website, and the websites that don't work are because of this warning. Try opening your console after you add the script and see if you get this warning when double clicking does not work.
As a fun project, I am working on creating a "Dark Mode" content script for a Google Chrome Extension. I know the project might sound silly because of all the dark mode readers already available for all apps, but I am just trying to start small with the extensions and because I use the dark-mode reader so often, it seemed obvious to start with this.
The content-script itself hasn't caused me much issue, but I am running into trouble between the time it takes for the page to load and the content-script to run. Although there is a very small difference in time, it is annoying to briefly see a bright-white page when I'm in the dark before the content-script activates to make everything dark again. I understand that there is this command that I can add to the manifest:
"run_at": "document_start",
but this ends up causing no changes to the page. It seems that running at "document_start" might not give time for all the HTML to load, thereby preventing the script from actually changing anything. Does anyone have any advice to at least give an illusion of the content-script running immediately so I don't see the original page and then the content-script modified page? I want the changes to be more seamless and I don't notice the page actively changing if that makes sense.
Why don't you try by keeping the script tag at the bottom of the body tag.
<body>
.
.
<script>
</script>
<body>
So, I'm kinda new to jquery, and this is the first time I've had to deal with the issue I'm having at the moment.
I think it's an interference with Wordpress suddenly updating to 3.9 - 3.9.1 or something, though I can't specifically nail it down.
So the way this site works is that I had the boxes with the videos work like they do now, you clicked play and it would pop up in a fancybox and start playing the video.
It still does this - however, it will just show the loader, and not actually load the fancybox.
And before you ask, I could only get it working in the first place with jquery 1.11, due to various conflicts, but now it suddenly wont work at all.
http://ramborg.com/commercial <- You can see the issue here.
The videos shown are mostly Vimeo, I'm pretty sure they all are, but maybe there has been some YT also added, but that wouldn't matter, if the media helper actually worked.
Any ideas, and input would be greatly appreciated, before I just revert down to an older version of WP to make it work again.
EDIT: Appearntly the fancybox will EVENTUALLY load, it's just heavily delayed. It took like 1-2 minutes into a video before it loaded. If you goto Stills the fancybox will load almost right away (it's just an image). It's almost like it wont open the fancybox until the video is done buffering?
EDIT2: From what I can garner from console/inspect in Chrome, is that it's struggling with loading player.js from Vimeo? Is that the error the rest of you see aswell? Any way I could solve this issue?
I just checked. The videos all load promptly, and no errors in the console in chrome. Try loading the page both while logged in to wordpress and logged out to see if there is a difference.
I have a situation where I'm inserting javascript generated HTML code into a DIV. One would think this would be a no brainer, but for some reason, once the code is in, the status bar and tab loading graphics start up in both browsers and never stop again. The page continually appears to be loading data, but in reality, there's nothing more to load. Any idea why this may be happening? Solutions? I appreciate any help. Thanks!
Install the Firebug plug-in for Firefox. Open it up and got to the NET tab. That will allow you to see your network activity. Something on the server may be stalling. This will help you find it.
I want to debug a javascript file that is embedded in the HEAD element.
I navigate to the site, see the code, and make a breakpoint:
(source: deviantsart.com)
But when I click on Reload, the script disappears and it doesn't stop at the breakpoint:
(source: deviantsart.com)
Debugging was working earlier so I know it works in general. What do I have to do so that Firebug always debugs my script?
I've noticed this behaviour before as well. It seems that it can happen if you refresh the page while the debugger is running (i.e. after you've hit your breakpoint and are stepping through code). This is far from conclusive, just something I've casually observed over time.
Also, I try to avoid having multiple tabs open with firebug active, as it seems to get confused.
Edit: just thought I'd add that I've seen this manifest itself in a few different ways:
the external script file does not appear at all in the scripts panel.
the external script file appears but firebug doesn't "see" it. You know this has happened because the line numbers beside the code where a breakpoint can be set won't be highlighted (used to be green but now appear to be just a darker shade than other lines). I've seen this happen with inline javascript on a HTML page (horrors!) as well.
the external script file is there, but you can only see a single screen full of code. Where "screen full" is the firebug panel viewport.
shut down firefox and then restart. sometimes firebug gets confused. also make sure you have the latest version.
You need activate the script tab
I'm not sure that having a <script> inside <head> (as opposed to, inside <body>) is actually legal HTML. If it's not, as I suspect, you can't fault Firebug for not supporting it well...!-)
The bugs in script processing that I know about are 1) jquery dynamic loading of scripts fails, 2) new Function() cannot be seen, 3) some kinds of document.write() cannot be seen.
Firebug processes script files in series with Firefox. This means that Firebug must be active when the page loads and it means that any exception in the path will cause the files to be mis-processed. If you opened firebug before loading and you still see problems, then the most likely fix is to install Firebug in a new Firefox profile. This causes you to get a completely fresh set of default options and you run Firebug without other extensions. As you re-add other extensions, look for problems in seeing scripts: then maybe you will discover what extension is interfering with the code path for processing scripts. I know this is a pain in the neck, but so is JS debugging without source ;-). We are working on testing with more Firebug and Firefox extensions installed to try to reduce these problems.
In our case it was the bundling of JS files.
It is not only FireFox, it is same for Chrome.
We moved the file out of the bundle and put it on the page where it needed to be referenced and it started working like charm.