greasemonkey

Why is $ undefined when I try to use jQuery in GreaseMonkey?

前提是你 提交于 2019-12-04 04:35:50
I'm totally new to GreaseMonkey, but I'm trying to make a little script. // ==UserScript== // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js // ==/UserScript== (function() { $ = unsafeWindow.jQuery; alert($); // this gives 'undefined' }()); Why does the alert give undefined and how to fix this? UPDATE I tried this: (function(){ //boilerplate greasemonkey to wait until jQuery is defined... function GM_wait() { alert('ok'); if(typeof unsafeWindow.jQuery == 'undefined') window.setTimeout(GM_wait,100); else unsafeWindow.jQuery(function() { letsJQuery(unsafeWindow.jQuery); });

Call href from JavaScript

柔情痞子 提交于 2019-12-04 03:53:18
This is the same question as THIS ONE , I can't answer that anymore, so I'm re-posting it with my account. Sorry for the mess. I need a Greasemonkey script that on a page load activates a href link like 'javascript:FUNCTION'. I've seen this code: <script language="Javascript" type="text/javascript"> function somescript() { window.location.href = document.getElementById('ololo').href; } </script> <a href="javascript:alert('test');" id="ololo">test</a> <br /> <a href="javascript:somescript()">click me</a> and, while it works on a local page even when using onload, it doesn't work when I use it

ReferenceError: GM_xmlhttpRequest is not defined

随声附和 提交于 2019-12-04 02:57:13
I get a ReferenceError in the following userscript code: // ==UserScript== // @name ... // @namespace ... // @description ... // @include ... // @grant GM_xmlhttpRequest // ==/UserScript== console.log(GM_info); try { console.log(GM_xmlhttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState); } catch (e) { console.log(e); } ... It first logs GM_info successfully, then logs the ReferenceError. (I'm using Firefox/Firebug.) ReferenceError: GM_xmlhttpRequest is not defined Why do I get this error? I had the same problem, and what fixed it for me was adding this at the

XPath not working to click a button from a Greasemonkey script

会有一股神秘感。 提交于 2019-12-04 02:04:12
问题 I would like to open a link that contains the word google . It looks like this: <input class="submit" style="background: #409999; border-radius: 10px;" value="open" onclick="Open('143615', '1', 'https://www.google.de/');" type="submit"> I tried this Greasemonkey code: var snapResults = document.evaluate("//input[contains(@onclick, 'test')]",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = snapResults.snapshotLength - 1; i >= 0; i--) { var elm = snapResults

Accessing Greasemonkey metadata from within your script?

岁酱吖の 提交于 2019-12-04 01:18:02
Is there any way that my script can retrieve metadata values that are declared in its own header? I don't see anything promising in the API, except perhaps GM_getValue() . That would of course involve a special name syntax. I have tried, for example: GM_getValue("@name") . The motivation here is to avoid redundant specification. If GM metadata is not directly accessible, perhaps there's a way to read the body of the script itself. It's certainly in memory somewhere, and it wouldn't be too awfully hard to parse for "// @" . (That may be necessary in my case any way, since the value I'm really

How to sync locally hosted Greasemonkey scripts across multiple machines?

落爺英雄遲暮 提交于 2019-12-04 00:57:38
I wish to have access to my Greasemonkey scripts across all machines I use. I already enabled the ' Enable Firefox Sync for User Scripts ' setting on Greasemonkey's settings dialog, but then I read that it only syncs externally hosted scripts . Then I attempted to set up synching with the following method: I moved Greasemonkey's ' gm_scripts ' folder (located in %appdata%\Mozilla\Firefox\Profiles\<profile name> ) to a OneDrive folder. I created a symlink in the original place pointing to the OneDrive folder mentioned above: mklink /D gm_scripts "%userprofile%\SkyDrive\App Profile Synching

Attempt to add a rule to a CSS stylesheet gives “The operation is insecure” in Firefox

99封情书 提交于 2019-12-04 00:02:55
问题 I'm using Greasemonkey and trying to add a rule in a specific domain. But it results in an error saying The operation is insecure . The code works fine on Chrome. The script runs on http://mydomain.com/test/test.php And the CSS file is http://cdn.mydomain.com/test/css/global.css My function: function css(selector, property, value) { for (var i=0; i<document.styleSheets.length;i++) { try { document.styleSheets[i].insertRule(selector+ ' {'+property+':'+value+'}', document.styleSheets[i]

Update page to add new link using Greasemonkey

Deadly 提交于 2019-12-03 21:23:44
JScript does my head in most days, but poorly designed sites do it even more. Foursquare's is one such example in respect of its superusers. Desired Outcome A greasemonkey script that will look through each occurrence of the DIV class searchResult , and after the DIV class name append two new A HREF elements similar to these: <a href="/venue/venueid/edit">Manage venue</a> <a href="/edit_venue?vid=venueid">Edit venue</a> Scenairo I would like to make the life of their superusers a little easier using Greasemonkey. The intent is to modify a specific page on the site ( https://foursquare.com

jQuery UI Dialog Throw Errors When Invoked from Greasemonkey

假如想象 提交于 2019-12-03 21:05:51
I'm getting this awkward error any time I try and create a dialog from Greasemonkey... I believe it has to do with the limitations of XPCNativeWrapper https://developer.mozilla.org/en/XPCNativeWrapper#Limitations_of_XPCNativeWrapper , though I am not 100% sure. None of the core jQuery methods that I've used have caused errors (append, css, submit, keydown, each, ...). It is possible that this could be an error in Greasemonkey or due to the interaction between Greasemonkey and jquery ui, but I am really interested in figuring out how to get them to work together. // ==UserScript== // @name

How to debug Greasemonkey script on Firefox 30?

末鹿安然 提交于 2019-12-03 17:22:51
I've been developing a JavaScript snippet for Youtube which uses Greasemonkey, and also imports Bootstrap and jQuery libraries. This application has to add a button for each one of the search list results and when the user clicks it, it must bring the user uploaded videos from his channel. I've tested the button and it works well on Firefox 29. Nevertheless, recently I updated Firefox to version 30, and now I'm unable to see/debug the code I wrote, although Firefox executes it. I'd like to know, if is there any solution to this issue? Here is the code if you would like seeing it: // =