alert a variable value
Note, while the above answers are correct, if you want, you can do something like: alert(“The variable named x1 has value: ” + x1);
Note, while the above answers are correct, if you want, you can do something like: alert(“The variable named x1 has value: ” + x1);
The only way to communicate with the code running on the page in Chrome is through the DOM, so you’ll have to use a hack like inserting a <script> tag with your code. Note that this may prove buggy if your script needs to run before everything else on the page. EDIT: Here’s how the …
var full = window.location.host //window.location.host is subdomain.domain.com var parts = full.split(‘.’) var sub = parts[0] var domain = parts[1] var type = parts[2] //sub is ‘subdomain’, ‘domain’, type is ‘com’ var newUrl=”http://” + domain + ‘.’ + type + ‘/your/other/path/’ + subDomain window.open(newUrl);
The simplest, most robust way is to use the waitForKeyElements() utility. Here is a complete script that uses jQuery and waitForKeyElements to alter Amazon search results: // ==UserScript== // @name _Amazon Search, alter results // @include http://www.amazon.com/s/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @grant GM_addStyle // ==/UserScript== /*- The @grant directive is needed to …
The answer is no, there isn’t an internal id you can access. Opera and IE (maybe Safari?) support .sourceIndex (which changes if DOM does) but Firefox has nothing of this sort. You can simulate source-index by generating Xpath to a given node or finding the index of the node from document.getElementsByTagName(‘*’) which will always return …
Since you are using Tampermonkey (Chrome) and Greasemonkey (Firefox). Go ahead and use GM_setValue(). It cannot be cleared by Facebook or by any other website. It has the advantage of storing values cross-domain, as well. ~~~ Beware that the bog-standard GM_setValue() is somewhat problematic on Firefox. It can cause a script instance to crash on …
Yes, you can use jQuery selectors on data returned to mutation observer callbacks. See this jsFiddle. Suppose you had HTML like so and you set an observer, like so: var targetNodes = $(“.myclass”); var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var myObserver = new MutationObserver(mutationHandler); var obsConfig = { childList: true, characterData: true, attributes: true, subtree: …
You can send key events, and anything listening for them will get them, but they will not change the input, so you will not see the letter A appear, for example. This is mostly a security thing; see “Manually firing events” for a discussion about that. So, if you want the letter to appear, you …
Updatier: The Mene+Shuman fix now is busted with Firefox 30 and Firebug 2. Firefox 31 may provide workarounds (will investigate). In the meantime, use the “General workaround strategies” listed below. Update: This answer is now obsolete. If you open about:config and set extensions.firebug.filterSystemURLs to false then you can use Firebug to debug the Greasemonkey script …
The accepted answer is almost correct, but it could use a slight improvement: (function(open) { XMLHttpRequest.prototype.open = function() { this.addEventListener(“readystatechange”, function() { console.log(this.readyState); }, false); open.apply(this, arguments); }; })(XMLHttpRequest.prototype.open); Prefer using apply + arguments over call because then you don’t have to explicitly know all the arguments being given to open which could change!