userscripts

How can two instances of a userscript communicate between frames?

强颜欢笑 提交于 2019-11-26 09:46:17
问题 Refer to the technique of having the same JavaScript to run in both a web page and an iframe, as described in this answer: For example, suppose you have this page at domain_A.com: <html> <body> <iframe src=\"http://domain_B.com/SomePage.htm\"></iframe> </body> </html> If you set your @match directives like this: // @match http://domain_A.com/* // @match http://domain_B.com/* Then your script will run twice -- once on the main page and once on the iframe as though it were a standalone page.

Is there any way of passing additional data via custom events?

帅比萌擦擦* 提交于 2019-11-26 09:35:39
问题 I need to pass data between two autonomic user scripts - ideally without touching the unsafeWindow object - and I thought using custom events would be the way to go. I thought of something like this (let us disregard the MSIE model for the purpose of the example): addEventListener(\"customEvent\", function(e) { alert(e.data); }); var custom = document.createEvent(\"HTMLEvents\"); custom.initEvent(\"customEvent\", true, true); custom.data = \"Some data...\"; dispatchEvent(custom); This works

Add parameters to the URL (redirect) via a Greasemonkey/Tampermonkey/Userscript

守給你的承諾、 提交于 2019-11-26 08:34:05
问题 I\'d like to write a Greasemonkey/userscript that automatically adds .compact to URLs starting with https://pay.reddit.com/ so It automatically redirects me to the mobile version. I\'ve been looking at similar userscripts, particularly this one: https://userscripts.org/scripts/review/112568 trying to figure out how to edit the replacement pattern, but I lack skills in this domain. How do I write a Greasemonkey script that redirects me from https://pay.reddit.com/* to https://pay.reddit.com/*

Using ECMAScript 6

余生长醉 提交于 2019-11-26 06:55:24
问题 I\'m looking for a way to run ECMAScript 6 code in my browser\'s console but most browsers don\'t support functionality that I\'m looking for. For example Firefox is the only browser that supports arrow functions. Is there a way (extension, userscript, etc.) I can run these features on Chrome? 回答1: In Chrome, most of the ES6 features are hidden behind a flag called "Experimental JavaScript features". Visit chrome://flags/#enable-javascript-harmony , enable this flag, restart Chrome and you

Save images to hard disk WITHOUT prompt?

家住魔仙堡 提交于 2019-11-26 06:48:20
问题 I use twitter. Some people\'s tweets contain photos and I want to save them. I checked ifttt, where twitter is not a trigger. Thus, ifttt cannot help me do it. One idea is probably to use JavaScript. I use Firefox and installed Greasemonkey. I can write a Greasemonkey script (JavaScript) running on twitter website. Once I click \"retweet\" link or other button added by my script, my script examines the content of the tweet, find the URL of the photo, and save it to my disk. One problem is how

How can I load a shared web worker with a user-script?

。_饼干妹妹 提交于 2019-11-26 06:40:58
问题 I want to load a shared worker with a user-script. The problem is the user-script is free, and has no business model for hosting a file - nor would I want to use a server, even a free one, to host one tiny file. Regardless, I tried it and I (of course) get a same origin policy error: Uncaught SecurityError: Failed to construct \'SharedWorker\': Script at \'https://cdn.rawgit.com/viziionary/Nacho-Bot/master/webworker.js\' cannot be accessed from origin \'http://stackoverflow.com\'. There\'s

Stop an input field in a form from being submitted

China☆狼群 提交于 2019-11-26 06:36:06
问题 I\'m writing some javascript (a greasemonkey/userscript) that will insert some input fields into a form on a website. The thing is, I don\'t want those input fields to affect the form in any way, I don\'t want them to be submitted when the form is submitted, I only want my javascript to have access to their values. Is there some way I could add some input fields into the middle of a form and not have them submitted when the form is submitted? Obviously the ideal thing would be for the input

Removing an anonymous event listener

大城市里の小女人 提交于 2019-11-26 03:39:53
问题 Is there anyway to remove an event listener added like this: element.addEventListener(event, function(){/* do work here */}, false); Without replacing the element? 回答1: There is no way to cleanly remove an event handler unless you stored a reference to the event handler at creation. I will generally add these to the main object on that page, then you can iterate and cleanly dispose of them when done with that object. 回答2: You could remove the event listener like this: element.addEventListener

Manually adding a Userscript to Google Chrome

守給你的承諾、 提交于 2019-11-26 00:50:53
问题 Instead of \"installing\" User-Scripts I found many tutorials on the web to add it manually. All of them told me to do the same steps: Make the directory C:\\Users\\Blabla\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\User Scripts Place a .js file there, which contains the User-Script Start Chrome with the parameter --enable-user-scripts I did so - but my demo script does not do anything: // ==UserScript== // @name Test // @description Test // @include http://example.com/* // @version

How can I use jQuery in Greasemonkey scripts in Google Chrome?

时光毁灭记忆、已成空白 提交于 2019-11-25 23:24:27
问题 As some of you may know, Google Chrome has put some severe limitation on Greasemonkey scripts. Chromium does not support @require , @resource , unsafeWindow , GM_registerMenuCommand , GM_setValue , or GM_getValue . Without require, I can\'t find a way to include the jQuery library in Greasemonkey script under Google Chrome. Does anybody have some advice in this matter? 回答1: From "User Script Tip: Using jQuery - Erik Vold's Blog" // ==UserScript== // @name jQuery For Chrome (A Cross Browser