greasemonkey

Using a regular expression in a Greasemonkey @include?

孤人 提交于 2019-12-05 09:59:22
I want to specify a bit better where my Greasemonkey script runs. // @include https://example.com/* Works fine, but it is too inaccurate, I want something like: // @include https://example.com/xx-xx/Asset/* xx could be any letter a-z, - is just dash, xx could be any letter a-z. My Idea was use regular expression for any 5 symbols, but I don't know how to properly use it. This is not working and lot more expression which I have tried to: // @include https://example.com/...../Asset/* Any idea how handle this? Update: This sort of works: // @include https://example.com/*/Asset/* See Include and

How to run a script every time a new page is loaded on YouTube?

余生颓废 提交于 2019-12-05 08:53:58
Since some time last year, YouTube made it so that every page is not actually loading an entirely new page, but primarily just re-loading the contents in div#content . You can notice this when you click on a link in YouTube and see the red loading bar at the top of the page. I have a Greasemonkey script that modified elements on YouTube, but now that YouTube doesn't reload the entire page, the Greasemonkey script no longer fires on every "new" page. How can I make the Greasemonkey script fire on every "new" page that I load on YouTube? I'm using jQuery in this Greasemonkey script. I tried

alert a variable value

你离开我真会死。 提交于 2019-12-05 08:43:05
问题 How do I display the value of a variable in javascript in an alert box? For example I've got a variable x=100 and alert(x) isn't working. the script used in grease monkey is here var inputs = document.getElementsByTagName('input'); var new; for (i=0; i<inputs.length; i++) { if (inputs[i].getAttribute("name") == "ans") { new=inputs[i].getAttribute("value")); alert(new) } } 回答1: A couple of things: You can't use new as a variable name, it's a reserved word. On input elements, you can just use

GM_log and other GM functions don't work in Greasemonkey scripts

隐身守侯 提交于 2019-12-05 07:23:25
I have created a "Hello World" Greasemonkey script in Firefox which contains only one line of code: GM_log("Hello World"); This did not seem to function, at least it did not produce any output in my firebug console. The same with other GM_... functions like GM_wait When I replaced: GM_log("Hello World"); with: alert("Hello World") it worked (so the script headers are not the problem). I have also set the following about:config options to true: javascript.options.showInConsole extensions.firebug.showChromeErrors extensions.firebug.showChromeMessages Is there some other setting to change for GM_

Local storage across domains using a Greasemonkey script

試著忘記壹切 提交于 2019-12-05 06:01:54
Is it possible to store data across domains using a Greasemonkey script? I want to allow a Javascript object to be accessed from multiple websites that are using the same Greasemonkey script. Yes, that is one of the purposes of GM_setvalue() , it stores data, per script , and across domains. Beware that the bog-standard GM_setValue() is somewhat problematic. It can use lots of global resources or cause a script instance to crash. Here are some guidelines: Do not use GM_setValue() to store anything but strings. For anything else, use a serializer such as GM_SuperValue . Even innocent looking

Greasemonkey - replace javascript src to load custom JS instead the one of the page

折月煮酒 提交于 2019-12-05 02:02:35
问题 There's specific webpage with variable in .js file. I want to rewrite the URL to be loaded with Greasemonkey, but still haven't got any results.The code I use is: window.addEventListener( 'load', function() { allTextareas = document.getElementsByTagName('script'); for (thisTextarea in allTextareas) { if( allTextareas[thisTextarea].getAttribute('src') == 'some url.js' ){ //allTextareas[thisTextarea].setAttribute('src', 'http://my custom url.js'); } } }, true); but it's not working. Can you

Executing JavaScript to Render HTML for Server-Side Caching

这一生的挚爱 提交于 2019-12-05 01:31:27
There are lots of widgets provided by sites that are effectively bits of JavaScript that generate HTML through DOM manipulation or document.write() . Rather than slow the browser down even more with additional requests and trust yet another provider to be fast, reliable and not change the widget output, I want to execute* the JavaScript to generate the rendered HTML, and then save that HTML source.­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­

How can you replace a link's target in Greasemonkey?

允我心安 提交于 2019-12-05 01:06:46
问题 I'm trying to write a script in Greasemonkey that will replace a link's target with something else, but with my limited Javascript knowledge I don't really know how to do this. Basically I'm trying to find all links containing a certain string of characters (ex: //a[contains(@href, 'xx')] ), and either replace them with another link, or append something to them (replacing 'abc123.com' with 'zyx987.com' or 'abc123.com' with 'abc123.com/folder'). If you could point me on the right path I'd

Using SmtpJS in a userscript: Doesn't work, no error messages?

浪子不回头ぞ 提交于 2019-12-04 19:11:23
I'm trying to send an email through a userscript using smtpjs because it seems the easiest approach. However it seems more difficult than just sending it by javascript that is embedded in a HTML page. Using this userscript ( based on the smtpjs website ) I get no error in the console and no email is sent, is this a framework issue or am I missing something here? (if you suggest an easier way to send emails within a userscript don't hesitate to share) // ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! //

How can I run a user script before any inline scripts run on a webpage?

女生的网名这么多〃 提交于 2019-12-04 18:40:03
问题 I want to make a greasemonkey type script for firefox that runs before the scripts on the page. Greasemonkey scripts run after scripts on the page, so that won't work. The reason I need this is because I want to edit one of the scripts on the page. Specifically, I want to delete a script that forces the page to load inside a frame since having the page inside a frame breaks F5 (Pressing F5 makes the page jump back to the front page instead of reloading the current page). Also, I don't want to