greasemonkey

@require-ing jQuery overwrites the page's $ variable

主宰稳场 提交于 2019-11-28 05:05:53
问题 I'm @require -ing jQuery for my Greasemonkey script with this line in my script file: // @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js and it works quite well; I can use $('#id') to access the DOM. However, the $ variable of the 'real' page is modified (where $ is jQuery 1.2.xx): I get an error that $.include is not defined. I thought the sandbox model of Greasemonkey would prevent that the variables of the target-page are overwritten? How can I ensure that the

How to simulate typing in input field using jQuery?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 04:29:55
What I want is to simulate typing in <input> field using javascript. I have the following code: var press = jQuery.Event("keydown"); press.ctrlKey = false; press.which = 65; $("#test").trigger(press); But when I load the page, the #test input field has no typed characters, the keycode of '65' represents 'A', but there is no 'A' input. Basically what I want is to automatically typing in the website using Greasemonkey. Please give me some ideas or some library with which I can use to do this. Thanks a lot! You can send key events, and anything listening for them will get them, but they will not

Can jQuery selectors be used with DOM mutation observers?

一曲冷凌霜 提交于 2019-11-28 03:34:32
HTML5 includes a concept of "mutation observers" to monitor changes to the browser's DOM. Your observer callback will be passed data which looks a lot like DOM tree snippets. I don't know if they are exactly this or how they work really. But when you are writing code to interact with a 3rd party site over which you have no control, say with a Greasemonkey script or Google Chrome user script, you have to inspect the tree of elements passed in to find which information is relevant to you. This is much simpler with selectors, just like working with any DOM, than walking the tree manually,

TypeError: Cannot read property 'click' of null

我们两清 提交于 2019-11-28 03:28:30
问题 I have been mass following / unfollowing / favoriting / unfavoriting on twitter with these codes ; $('button.follow-button').click(); $('button.ProfileTweet-actionButtonUndo').click(); $('a.favorite').click(); I found some not-working codes online and tried to fix, so they are nearly working now. The only thing is to go to the page on google chrome, press f12 , open console and run the command. So now, I wanted to use the same system in Vine. There"s an extension for google chrome to use vine

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

Watch for element creation in greasemonkey script?

故事扮演 提交于 2019-11-27 23:07:55
I need to be notified when an element with class 'nav' is created as the document is loading. Googling I found MutationObservers and thought they would be perfect, but I can't seem to get it working. // ==UserScript== // @name ii-shortcuts // @namespace https://github.com/RedHatter // @include * // @version 1 // @run-at document-start // ==/UserScript== var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.target.getAttribute('class') == 'nav') GM_log('nav creation'); }); }); observer.observe(document, {subtree: true, attributes: true,

how to use the google maps api with greasemonkey to read a table of addresses and trace the route?

允我心安 提交于 2019-11-27 22:30:53
There is a website which holds the buses routes for my city ( Porto Alegre - Brazil) in a table. ex: EPTC Using Greasemonkey to load de Google Maps API , id like to show a fixed map at the top right corner of the screeen. The script must read the street names from the table, strip de extra spaces (there are a lot of them), and draw the route in the right order. Here is the Greasemonkey compatible script to accomplish the task: http://userscripts.org/scripts/show/116339 Key points: 1- find the table and loop through each cell to get the content 2- strip all the extra white spaces and save the

Why doesn't document.addEventListener('load', function) work in a greasemonkey script?

丶灬走出姿态 提交于 2019-11-27 21:46:50
It doesn't give an error, and I put a console.log('loaded userscript wifi-autologin') , the console.log works, but the intended effect of the document.addEventListener doesn't happen. After doing a bit more debugging, making it print that the addEventListener was called, I discovered that it wasn't being called. Source of script: // ==UserScript== // @name wifi-autologin // @namespace lf-ns // @description Hopefully autologins to a captive portal // @include *://1.1.1.1/* // @version 1 // @run-at document-end // ==/UserScript== document.addEventListener('load', submitAction); Apparently,