greasemonkey

Closure in Javascript [duplicate]

守給你的承諾、 提交于 2019-11-26 11:28:04
问题 Possible Duplicate: Passing values to onclick I have 100 elements with ids divNum0 ,..., divNum99 . Each when clicked should call doTask with the right parameter. The code below unfortunately does not close i, and hence doTask is called with 100 for all the elements. function doTask(x) {alert(x);} for (var i=0; i<100; ++i) { document.getElementById(\'divNum\'+i).addEventListener(\'click\',function() {doTask(i);},false); } Is there someway I can make the function called with right parameters?

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

How can you determine the file size in JavaScript?

不问归期 提交于 2019-11-26 11:22:48
问题 I help moderate a forum online, and on this forum we restrict the size of signatures. At the moment we test this via a simple Greasemonkey script I wrote; we wrap all signatures with a <div> , the script looks for them, and then measures the div\'s height and width. All the script does right now is make sure the signature resides in a particular height/width. I would like to start measuring the file size of the images inside of a signature automatically so that the script can automatically

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/*

Fire Greasemonkey script on AJAX request

非 Y 不嫁゛ 提交于 2019-11-26 07:59:50
I am working on a user script and I've just found that the script is not run when the main page makes AJAX requests. Is there any way to fire the user script both on main page load and on AJAX requests? Brock Adams The smart way to rerun the script's code on AJAX requests, is to focus on the key bits of the page and check for changes. For example, suppose a page contained HTML like so: <div id="userBlather"> <div class="comment"> Comment 1... </div> <div class="comment"> Comment 2... </div> ... </div> and you wanted the script to do something with each comment as it came in. Now you could

How to call Greasemonkey&#39;s GM_ functions from code that must run in the target page scope?

允我心安 提交于 2019-11-26 07:47:23
问题 I asked a question and got an answer here: How to call this YouTube function from Greasemonkey? That code works and adds a button to the page, which captures the video time. But, the key part must run in the target-page scope -- where Greasemonkey\'s GM_ functions are not available. I want to use GM_setValue() to record the video time. How do I call GM_setValue() from my button\'s click handler? Here is the relevant part of the complete script (right-click to save): ... ... //-- Only run in

How to exclude iframe in Greasemonkey or Tampermonkey?

霸气de小男生 提交于 2019-11-26 07:43:54
问题 I have created a Greasemonkey script for a website. What the script does is adding a div at the end of the page. document.body.insertBefore(myDiv, document.body.firstChild); But now the site adds an iframe for google-ads, as a result my div appears in the iframe too, which is not what I want. How can I stop the script affecting iframes? 回答1: Greasemonkey now supports the @noframes directive (long supported by Tampermonkey and Scriptish). Use that for a cleaner way to block operation in

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 detect visited and unvisited links on a page?

隐身守侯 提交于 2019-11-26 06:44:56
问题 My aim is to detect the unvisited links on a webpage and then create a greasemonkey script to click on those links. By unvisited links here I mean the links which are not opened by me. Since I can see all the browser provide capability to change the color of visited and unvisited link is it possible to detect these links in any manner. While searching I came upon this link: http://www.mozdev.org/pipermail/greasemonkey/2005-November/006821.html but someone here told me that this is no longer

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