tampermonkey

Synchronous GM_xmlhttpRequest acting asynchronously?

牧云@^-^@ 提交于 2019-11-28 02:16:43
I'm trying to get a GM_xmlhttpRequest call to behave synchronously, but I can't get it to work like I expect: function myFunction (arg) { var a; GM_xmlhttpRequest ( { method: "GET", url: "http://example.com/sample/url", synchronous: true, onload: function (details) { a = details.responseText; } } ); return a; } b = myFunction (); alert (b); I never get anything back for b here; it's undefined. Is there some step that I'm missing here? I'm using v0.9.13 of Greasemonkey, and v9.0.1 of Firefox. Just stumbled upon this topic in Google. Synchronous GM_xmlhttpRequest RETURN the result instead of

Get 2 userscripts to interact with each other?

这一生的挚爱 提交于 2019-11-28 01:21:38
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. The scripts cannot directly interact with each other and // @namespace is just to resolve script name conflicts. (That is, you can have 2 different scripts named "Link Remover", only if they have different namespaces.) Separate scripts can

How can I handle multiple AJAX results in a userscript?

血红的双手。 提交于 2019-11-28 00:23:13
I'm currently developing a Greasemonkey script to translate <textarea> fields in an Intranet app, using Google Translation API. But some texts are way too large to be translated with only one request. I get this error when trying : Request entity too large Anyway, I found a way to cut the texts in fragments, and send them in separate requests. Where it gets tricky, is how I should replace those fragments in their original textareas, and especially at the right place. After trying several methods without any success, I inserted placeholders in the textarea, corresponding to the fragments of

Run a Greasemonkey script only once per page load?

我的梦境 提交于 2019-11-27 20:32:17
If you create a Greasemonkey script with @include * and go to a site like youtube, it runs the script 20+ times every time you refresh. This is on Firefox, not sure about Chrome. Is there a way to prevent this? First, you probably don't want the script to run in iFrames. You can block that using the @noframes directive which now works in both Greasemonkey and Tampermonkey as of October, 2014. For older versions, or for script engines that don't support @noframes , you can use this code, just after the metadata block: if (window.top != window.self) //don't run on frames or iframes { //Optional:

My Greasemonkey script is not finding the elements (links) on the page?

时光怂恿深爱的人放手 提交于 2019-11-27 19:35:16
问题 The website is: lexin.nada.kth.se/lexin/#searchinfo=both,swe_gre,hej; My script is: function main(){ var links=document.getElementsByTagName("a"); alert("There are " + links.length + "links."); } main(); Running the script gives me two alert messages saying There are 0 links. Any ideas why I can't get the right amount of links from the document? And why do I get the alert twice? 回答1: The alert fires more than once because that page contains iFrames (with, de facto, the same URL as the main

Why is usage of the downloadURL & updateURL keys called unusual and how do they work?

≡放荡痞女 提交于 2019-11-27 19:04:00
I was reading GM's wiki to determine the difference between @downloadURL & @updateURL (which I didn't). But what confused me even more that both are unadvised: It is unusual to specify this value. Most scripts should omit it. I'm surprised by that as it's the only way for scripts to auto-update and I don't see why these keys shouldn't be used. The wiki itself is pretty lacking and no other forum sources are advised, so I have to ask here. Also would appreciate more detailed info on these keys. Brock Adams Use of those keys is discouraged mainly by Greasemonkey's lead developer. Most others,

Greasemonkey to change value of Radio buttons in a form?

孤街浪徒 提交于 2019-11-27 16:22:22
I am writing a Greasemonkey/Tampermonkey script and I need to turn on radio buttons depending on the name and value of the radio control. This is how it looks: <input type="radio" name="11" value="XXX" class="radio"> <input type="radio" name="11" value="zzzz" class="radio"> So I want to set those buttons that have name of 11 and a value of zzzz to be checked. Brock Adams This is super easy when you use jQuery. Here's a complete script: // ==UserScript== // @name _Radio button check // @include http://YOUR_SITE/YOUR_PATH/* // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min

How/Where to store data in a Chrome Tampermonkey script?

我的未来我决定 提交于 2019-11-27 11:34:38
问题 I wrote one Greasemonkey/Tampermonkey script for Facebook . I needed to store data to retrieve it later. For that I used localStorage . That was working fine. But I noticed that after few hours all data which I stored was removed automagicllay. Probably Facebook itself deletes all localStorage data. Now, I searched for alternatives. Cookies : No this will be removed when user clears history. Web SQL : Apparently it is dropped by w3.org. So in near future I assume chrome might not be using web

Where are Chrome/Tampermonkey userscripts stored on the filesystem? [closed]

你说的曾经没有我的故事 提交于 2019-11-27 10:47:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Where are Chrome/Tampermonkey userscripts stored on the filesystem? I want to edit user scripts directly instead of using the hokey in-browser editor. 回答1: Tampermonkey scripts are super easy to update via the Tampermonkey tab. See the Tampermonkey FAQ, or just try it. Tampermonkey scripts were stored in a

How to use XMLHttpRequest to download an HTML page in the background and extract a text element from it?

百般思念 提交于 2019-11-27 09:38:17
I want to make a Greasemonkey script that, while you are in URL_1, the script parses the whole HTML web page of URL_2 in the background in order to extract a text element from it. To be specific, I want to download the whole page's HTML code (a Rotten Tomatoes page) in the background and store it in a variable and then use getElementsByClassName[0] in order to extract the text I want from the element with class name "critic_consensus". I've found this in MDN: HTML in XMLHttpRequest so, I ended up in this unfortunately non-working code: var xhr = new XMLHttpRequest(); xhr.onload = function() {