tampermonkey

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 handle multiple AJAX results in a userscript?

荒凉一梦 提交于 2019-11-26 21:41:41
问题 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

Run a Greasemonkey script only once per page load?

怎甘沉沦 提交于 2019-11-26 20:23:32
问题 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? 回答1: 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,

Replace many text terms, using Tampermonkey, without affecting URLs and not looking for classes or ids

会有一股神秘感。 提交于 2019-11-26 18:43:38
问题 I'm writing a Google Chrome extension for a popular e-commerce SAAS which will replace English text strings to Spanish inside its admin panel. I've come with a solution which replaces EVERYTHING, so when finding an a href, it also replaces it which is not desired: var els = document.getElementsByTagName("*"); for(var i = 0, l = els.length; i < l; i++) { var el = els[i]; // ==Menu_left_dropdown== el.innerHTML = el.innerHTML.replace(/View your user account/gi, 'Tu cuenta'); el.innerHTML = el

Greasemonkey to change value of Radio buttons in a form?

时间秒杀一切 提交于 2019-11-26 18:36:18
问题 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. 回答1: This is super easy when you use jQuery. Here's a complete script: // ==UserScript== // @name _Radio button check // @include http:

jQuery-UI is not working in my userscript without CSS, or with customization?

 ̄綄美尐妖づ 提交于 2019-11-26 17:51:58
I only want to use a tiny part of jQuery-UI (Menus) in a userscript I am making. jQuery-UI offers custom downloads, but I cannot find any links to specific modules, that I can @require in the script. Does anyone host the individual modules? Also, I have tried just requiring code.jquery.com/ui/1.11.1/jquery-ui.js , and the script crashes. Do I need to include some CSS with it as well? And also do some messy looking changes, like according to this answer ? Will that code be different for different JQUI versions? If I am only using a small part of the UI, does that change what I can safely delete

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

Storing user login/password input in a Greasemonkey script on install

只愿长相守 提交于 2019-11-26 16:35:17
I'm doing a Greasemonkey script that communicates with the Redmine ticket manager through the REST API. As the user needs to login to get the data from Redmine, I need a way to ask the user for his credentials at script installation and save them to the script. Can this be achieved without asking the user to edit the values directly in the script itself? EDIT: Since there is already an answer to this question I will validate the answer given just below as it is a very good framework. Here is a framework for getting and storing login credentials. † The script prompts for the information on the

How to use greasemonkey to selectively remove content from a website

守給你的承諾、 提交于 2019-11-26 15:27:19
The content I am trying to modify has a series of <div> entries, and within each of these are other <div> entries. There are no id tags to help here. What I want the script to do is inspect the content of each of these <div> entries and look for some text. This will be used to determine whether the whole '' entry is deleted/hidden or not. Is this possible? How? Below is an example. There are several of these in the page, and I want to delete/hide the ones where the text inside the <div class="foo bar"> tags say "Yes." So in this example, this whole thing would get deleted/hidden. <div class=

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

╄→尐↘猪︶ㄣ 提交于 2019-11-26 14:50:04
问题 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