userscripts

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

陌路散爱 提交于 2019-11-26 23:08:25
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/*.compact ? Thanks The script should do these things: Detect if the current URL is already to the compact

How to change a class CSS with a Greasemonkey/Tampermonkey script?

耗尽温柔 提交于 2019-11-26 22:06:38
I'm trying to set the background image of the body, but only where it uses the class banner_url . The HTML is as follows: <body id="app_body" class="banner_url desktopapp" data-backdrop-limit="1"> Basically, I would like to force the page to use the following CSS instead: .banner_url { background: url('http://www.pxleyes.com/images/contests/kiwis/fullsize/sourceimage.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } I am trying to do this using Greasemonkey if it makes any difference. Does

Get 2 userscripts to interact with each other?

怎甘沉沦 提交于 2019-11-26 21:52:39
问题 I have two scripts. I put them in the same namespace (the @namespace field). I'd like them to interactive with another. Specifically I want script A to set RunByDefault to 123. Have script B check if RunByDefault==123 or not and then have script A using a timeout or anything to call a function in script B . How do I do this? I'd hate to merge the scripts. 回答1: The scripts cannot directly interact with each other and // @namespace is just to resolve script name conflicts. (That is, you can

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

*爱你&永不变心* 提交于 2019-11-26 18:57:51
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 another way to load a web worker by converting the worker function to a string and then into a Blob and loading

Can I modify chrome://extensions/ page with JavaScript(user script)?

混江龙づ霸主 提交于 2019-11-26 18:36:44
问题 I'd like to use JavaScript to add a search bar for chrome://extensions/ page, so I created a file called test.user.js, and write scripts in it: // ==UserScript== // @name chromeex // @namespace chromeex // @version v1.0 /* @reason * just a test * @end */ // @match chrome://extensions/ // // ==/UserScript== (function(){ alert("haha"); }()); But when I load it in Chrome, it said Invalid header, finally I found out that it's @match chrome://extensions/ that cause the error. Is there a walkaround

Clicking a button on a page using a Greasemonkey/userscript in Chrome

巧了我就是萌 提交于 2019-11-26 18:36:18
问题 I'm going to be as absolutely verbose here as possible as I've run into a few solutions that didn't end up panning out. Please keep in mind that I don't know Javascript . I know basic HTML and CSS. I don't have any actual programming background but I'm trying to learn bit by bit by researching basic tasks like this. Please talk to me like I'm an idiot. Any lingo I throw around in this post I learned while researching this specific issue. I'm writing this userscript as a personal project and

Save images to hard disk WITHOUT prompt?

依然范特西╮ 提交于 2019-11-26 16:42:16
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 to save the image. I searched the Internet. Some use win.document.execCommand("SaveAs") , and it will

Removing an anonymous event listener

喜欢而已 提交于 2019-11-26 15:22:43
Is there anyway to remove an event listener added like this: element.addEventListener(event, function(){/* do work here */}, false); Without replacing the element? 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. You could remove the event listener like this: element.addEventListener("click", function clicked() { element.removeEventListener("click", clicked, false); }, false); Tiny Giant

Injecting JS functions into the page from a Greasemonkey script on Chrome

99封情书 提交于 2019-11-26 15:09:27
I have a Greasemonkey script that works just fine in Firefox and Opera. I struggle with getting it to work in Chrome, however. The problem is injecting a function into the page that can be invoked by code from the page. Here's what I'm doing so far: First, I get a helper reference to the unsafeWindow for Firefox. This allows me to have the same code for FF and Opera (and Chrome, I thought). var uw = (this.unsafeWindow) ? this.unsafeWindow : window; Next, I inject a function into the page. It's really just a very thin wrapper that does nothing but invoking the corresponding function in the

How to override the alert function with a userscript?

故事扮演 提交于 2019-11-26 11:24:00
问题 On site there is code like that (its site on LAN) <script language=\"JavaScript\" type=\"text/javascript\"> alert(\"ble\"); </script> I try to disable that alert using GM. I was trying to do this unsafeWindow.alert=function() {}; but I see the alert and get this error Error: uncaught exception: [Exception... \"Component is not available\" nsresult: \"0x80040111 (NS_ERROR_NOT_AVAILABLE)\" location: \"JS frame :: file:///C:/Documents%20and%20Settings/arokitnicki/Dane%20aplikacji/Mozilla/Firefox