greasemonkey

Binding to an event of the unsafeWindow in Firefox 30 with Greasemonkey 2.0

蹲街弑〆低调 提交于 2019-12-05 19:55:38
I'm maintaining a Greasemonkey script and got some trouble due to Mozilla's change to the unsafeWindow API in Firefox 30. The page my script runs on, triggers an event "MyEvent" and my script is interested in that event. The event is fired using jQuery 1.6.4 Before, I used this code to hook into this event: var jQuery = unsafeWindow.jQuery; jQuery(unsafeWindow.document) .bind("MyEvent", function() { console.log("MyEvent Triggered!"); }); But due to Mozilla's change this won’t work anymore. I tried to insert my own jQuery in conflict-free mode but I don't think this can access events that are

Greasemonkey script to move an element into another element?

喜欢而已 提交于 2019-12-05 19:08:20
I want to move <div> elements. In this case, swap the first and last div.clearfix . So this: <fieldset> <div class="clearfix "> <label for="form-title">Title</label> <div class="input"></div> </div> <div class="clearfix "></div> <div class="clearfix "> <label>Verification</label> <div dir="ltr"> recaptcha </div> </div> </fieldset> Would become this: <fieldset> <div class="clearfix "> <label>Verification</label> <div dir="ltr"> recaptcha </div> </div> <div class="clearfix "></div> <div class="clearfix "> <label for="form-title">Title</label> <div class="input"></div> </div> </fieldset> I've

How can my userscript get a link based on the link's text?

佐手、 提交于 2019-12-05 18:39:36
Given this HTML on the target page: <dd class="ddTit"> <a href="http://abc.xxx.com/54781.html" target="_blank">special text words</a> </dd> How can I get the url based on the " special text words ", and do the click in a Greasemonkey script? I tried this: var textlink = document.querySelector ("dd.ddTit a[textContent*='special']"); var clickEvent = document.createEvent ('MouseEvents'); clickEvent.initEvent ('click', true, true); textlink.dispatchEvent (clickEvent); with no luck. How do I select based on the textContent , such as textContent contains the word special ? Brock Adams Alas, you

Looking for Greasemonkey Scriptwriting basics/tutorial [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-05 18:22:20
问题 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 4 years ago . I have been searching the internet for days now trying to find out how to write my own script, one more complicated than the "Hello World" script. I understand for the most part how to find specific elements using firebug (I have Firefox). I understand the metadata and how to do all that. I do not however

Parse Greasemonkey metadata and/or grab comments from within a function

佐手、 提交于 2019-12-05 16:52:36
function blah(_x) { console.info(_x.toSource().match(/\/\/\s*@version\s+(.*)\s*\n/i)); } function foobar() { // ==UserScript== // @version 1.2.3.4 // ==/UserScript== blah(arguments.callee); } foobar(); Is there any way to do this using JavaScript? I want to detect the version number / other attributes in a Greasemonkey script but as I understand it, .toSource() and .toString() strip out comments 1 . I don't want to wrap the header block in <><![CDATA[ ]><> if I can avoid it, and I want to avoid having to duplicate the header block outside of the comments if possible. Is this possible? Are

How do I efficiently access gzipped xml from javascript?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 16:23:06
I need to efficently access a large gzipped xml file from javascript (actually from Greasemonkey). Unfortunately, the server doesn't provide a Content-Encoding header, and Content-Type is "application/x-gzip", so firefox will not (as far as I can tell) automatically inflate it. If there's a way to fake firefox out, that would be ideal. Short of that, I need some way to efficiently do the inflation...what I'm using now takes about 30 seconds to deflate the 1.2Mb gzipped file; I'd like to get it down under 5 seconds. (The Greasemonkey script I'm working on can't have any other external server

setTimeout not always working in Greasemonkey

三世轮回 提交于 2019-12-05 14:57:20
I've found a lot of similar problems but none equal and no right solution. This is a very strange issue. I have a simple Greasemonkey script to test the issue: // ==UserScript== // @name testdiddio // @namespace http://userscripts.org/users/useridnumber // @include https://www.google.it/ // @version 1 // ==/UserScript== function wait(){ console.info("wait"); setTimeout(wait,1000); } console.info("start"); wait(); This is the output from firebug: start wait wait wait wait The wait() function is called 4 times then stops. If I set the Timeout to 100ms the call seems works for at least 10/15

'document' is undefined in Greasemonkey

允我心安 提交于 2019-12-05 14:16:31
Not more than ten minutes ago I decided to write my first script for Greasemonkey. I have zero experience with it. Also, my JavaScript is a bit rusty as it's been a while since I last wrote code in it. But I can't figure out why Greasemonkey is giving me this error: Line: 9 Char: 2 Error: 'document' is undefined Code: 800A1391 Source: Microsoft JScript runtime error Here's my script: // ==UserScript== // @name Easier WatchSeries // @namespace n/a // @include http://www.watch-series.com/episode/* // ==/UserScript== function thing() { document.body.setAttribute('onload', show_links(document

Greasemonkey with jQuery, how to write the greasemonkey script to modify page DOM elements?

泪湿孤枕 提交于 2019-12-05 10:34:01
问题 From the greasemonkey wiki page, there is an example using jQuery with greasemonkey. The code is listed below and the location of the page is http://wiki.greasespot.net/Third-Party_Libraries#jQuery // ==UserScript== // @name jQuery Example // @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js // ==/UserScript== // Append some text to the element with id someText using the jQuery library. $("#someText").append(" more text."); This example script modify the DOM directly.

Replace javascript function using greasemonkey

狂风中的少年 提交于 2019-12-05 10:08:41
I want to change the script using greasemonkey. But it doesn't work. Please help; original script <script> function abc(){ // SOME STUFF HERE } abc(); window.onload = abc; ..... // OTHER JAVASCRIPT TASK ..... </script> Now I want to change the function abc as my requirement. I tried the following way but doesn't help. // ==UserScript== // @name Test // @namespace UNIQUE_NAMESPACE // @include http://PATH_TO_DOMAIN/* // @version 1 // @grant unsafeWindow // ==/UserScript== unsafeWindow.abc= function () { //MY REQUIREMENT } You will find a good example/tutorial here: @document-start Example: