userscripts

Why is script.onload not working in a Chrome userscript?

血红的双手。 提交于 2019-12-01 05:54:29
I want to load another script file, in a site, using a userscript. But, the js.onload event doesn't work correctly. The userscript file: // ==UserScript== // @name Code highlight // @description Test // @include http://localhost/* // @version 1.0 // ==/UserScript== var js = document.createElement('script'); js.src = "http://localhost/test/js/load.js"; document.getElementsByTagName("head")[0].appendChild(js); js.onload = function(){ console.log(A) } the load.js file: var A = { name:'aa' } In Chrome, the console outputs "undefined", but the load.js has loaded completely. I tested it in Firefox,

window.onload works in Firefox+Greasemonkey script but not in a Chrome userscript?

℡╲_俬逩灬. 提交于 2019-12-01 04:21:14
There is a page http://example.com/1.php that includes javascript file as usual: <script type="text/javascript" src="/util.js?1354729400"></script> This file contain function named exampleFunction which I need to use in my userscript. Also I have an user script: // ==UserScript== // @name SomeName // @namespace http://example.com/userscripts // @description Greets the world // @include http://example.com/* // ==/UserScript== window.onload = function () { console.log(exampleFunction); alert("LOADED!"); } which works perfectly in Firefox and returns an error in Chrome: Uncaught ReferenceError:

Why is script.onload not working in a Chrome userscript?

帅比萌擦擦* 提交于 2019-12-01 03:35:56
问题 I want to load another script file, in a site, using a userscript. But, the js.onload event doesn't work correctly. The userscript file: // ==UserScript== // @name Code highlight // @description Test // @include http://localhost/* // @version 1.0 // ==/UserScript== var js = document.createElement('script'); js.src = "http://localhost/test/js/load.js"; document.getElementsByTagName("head")[0].appendChild(js); js.onload = function(){ console.log(A) } the load.js file: var A = { name:'aa' } In

Possible to run userscript in IE11

不想你离开。 提交于 2019-12-01 03:01:37
I have a custom userscript that I'm running in Chrome and Firefox using Tampermonkey/Greasemonkey. Is there any way of using this script in IE11? Or is there any plugins for IE11 that does what Tampermonkey/Greasemonkey does? DasBeasto TrixIE WPF4.5 claims to emulate Greasemonkey on IE11. Unfortunately, the original Trixie and IE7Pro stopped working around IE8-ish. A simple Google Search (I searched "greasemonkey for IE") yields various alternatives available for other browsers: http://en.wikipedia.org/wiki/Greasemonkey#Equivalents_for_other_browsers For Internet Explorer, similar

GM_xmlhttpRequest data is being placed in the wrong places

六眼飞鱼酱① 提交于 2019-12-01 01:51:54
I am using the following excellent userscript (for Chrome, Chrome's Tampermonkey and Firefox Greasemonkey). It's supposed to display movie ratings next to each IMDb movie link, but it stopped working properly. This is the complete script: // ==UserScript== // @name Add IMDb rating next to all IMDb links (+voter count) // @author Ali // @description Adds movie ratings and number of voters to any IMDb link. Modified version of http://userscripts.org/scripts/show/9174 // @include * // @version 2013-05-12 // @namespace http://userscripts.org/scripts/show/96884 // @grant GM_xmlhttpRequest //

Are Chrome user-scripts separated from the global namespace like Greasemonkey scripts?

痴心易碎 提交于 2019-11-30 21:39:29
I know Greasemonkey scripts are automatically wrapped in anonymous functions isolated in some way in order to prevent them conflicting with scripts in the page. Does the same happen with Chrome user-scripts? Yes, Greasemonkey scripts are normally wrapped in an anonymous function . And, Chrome userscripts apparently are too . But, more importantly, Greasemonkey scripts are usually 1 wrapped in an XPCNativeWrapper sandbox, while Google Chrome converts userscripts into extensions, and they operate in an arena that Google calls an "isolated world" 2 . So, you don't need to wrap your script code in

GM_xmlhttpRequest data is being placed in the wrong places

痞子三分冷 提交于 2019-11-30 21:12:11
问题 I am using the following excellent userscript (for Chrome, Chrome's Tampermonkey and Firefox Greasemonkey). It's supposed to display movie ratings next to each IMDb movie link, but it stopped working properly. This is the complete script: // ==UserScript== // @name Add IMDb rating next to all IMDb links (+voter count) // @author Ali // @description Adds movie ratings and number of voters to any IMDb link. Modified version of http://userscripts.org/scripts/show/9174 // @include * // @version

Is it possible to determine if Chrome is in incognito mode via a user-script?

自作多情 提交于 2019-11-30 13:11:53
问题 I asked this question before but didn't make it clear that I meant in user script, not in JavaScript from a webpage.So I'll be more clear now. Is it possible to determine if Google Chrome is in incognito mode via a user-script (basically a script run as an extension in the browser, not a script being run on a webpage)? 回答1: If you are developing an Extension then you can use the tabs API to determine if a window/tab incognito. More information can be found on code.google.com. If you are just

How to make a script redirect only once every time an appropriate page loads?

我只是一个虾纸丫 提交于 2019-11-30 09:45:37
问题 I'm writing a Tampermonkey script that I want to use to redirect from youtube.com/* to a YouTube channel address. window.addEventListener ("load", LocalMain, false); function LocalMain () { location.replace("https://www.youtube.com/channel/*"); } When the script is running it redirects to the channel URL but then keeps running and continuously redirects . 回答1: You need to check if the current pathname includes channel before reassigning a new href function LocalMain () { if(!location.pathname

How can I have a Tampermonkey userscript play a sound when a specific word appears on a page?

倖福魔咒の 提交于 2019-11-30 09:44:35
问题 In a chat room, when someone pastes a certain word into the chat I want the browser to make a noise to alert me. It seems like Tampermonkey should be able to do this, but I don't know how to start and searching turns up few, and inapplicable results. (This other question seems close but the answer just plays a sound every 5 seconds no matter what!) How can a userscript alert when a target word appears via AJAX? 回答1: Set up a MutationObserver to watch for the target word. Then use HTML5 Audio