greasemonkey

Changing Javascript on an HTML page out of my control [duplicate]

ε祈祈猫儿з 提交于 2019-11-28 09:30:01
This question already has an answer here: Stop execution of Javascript function (client side) or tweak it 4 answers I'm using an HTML page out of my control. It defines a Javascript function in an inline <script> tag and calls it in <body onload="..."> : <html> ... <body onload="init()"> <script type="text/javascript" language="javascript"> function init() { ... } </script> ... How can I change that function before it's called? I've tried to use Greasemonkey to modify the script or to insert another script just after it to override the function, but it doesn't seem to have any effect. Brock

How do I reload a Greasemonkey script when AJAX changes the URL without reloading the page?

送分小仙女□ 提交于 2019-11-28 09:22:06
I have an application that I am trying to create a Greasemonkey script for. It utilizes a lot of jQuery and AJAX to load content dynamically. I've noticed that the URL does change each time I load a new item, even though the page doesn't refresh. Is there a listener I can place on the page to relaunch the script each time the URL changes? Brock Adams How you do this depends on the site/application and on what you are trying to do. Here are your options , easiest and most robust first: Don't try to catch URL changes. Use calls to waitForKeyElements() to act on the parts of the various pages

Override default jQuery selector context

断了今生、忘了曾经 提交于 2019-11-28 09:05:25
I'm trying to use jQuery inside a Firefox extension, and actually want to use jQuery to manipulate the DOM of the current page, as opposed to the context of the XUL file. Thus, I load jQuery in my XUL file, and pass it to some of my scripts in a sandbox (using the Greasemonkey extension compiler http://arantius.com/misc/greasemonkey/script-compiler ). Since jQuery was not loaded with the page DOM, I want to set its selector context to the page DOM instead of always passing it into jQuery calls. I followed the solution at How to use jQuery in Firefox Extension and it almost achieves what I want

Redirect faster with Greasemonkey (or similar userscript engine)?

▼魔方 西西 提交于 2019-11-28 08:50:30
I'm using Greasemonkey to redirect certain URLs to another but I would like to redirect before the URL to be redirect loads. Currently I'm using this simple script: //==UserScript== // @name Redirect Google // @description Redirect Google to Yahoo! // @include http://*.google.com/* //==/UserScript== window.location.replace("http://www.yahoo.com") In the above, Google appears for a second and then redirected to Google. I want to go yahoo immediately. Is it possible, and how? user873792 You can use @run-at document-start in the metadata block Doc . EG: //==UserScript== // @name Redirect Google /

Adding a @grant value breaks my Greasemonkey+jQuery script?

一个人想着一个人 提交于 2019-11-28 08:38:23
问题 When I add the @grant for GM_xmlhttpRequest, I get: Error: Permission denied to access property 'call' in the jQuery file. If I remove the grant, it works fine. // ==UserScript== // @name Dimi Test // @namespace Dimi // @include about:addons // @version 1 // @grant GM_xmlhttpRequest // @include http://*.myDomain.*/* // ==/UserScript== var $J = unsafeWindow.jQuery; $J(unsafeWindow.document).ready(function(){ alert('Hello'); }); 回答1: See "Error: Permission denied to access property 'handler'".

How to convert a bookmarklet into a Greasemonkey userscript?

余生颓废 提交于 2019-11-28 07:50:11
Is there a easy way to do this. And is there anything that needs to be changed due to differences in how it is ran? Brock Adams The easiest way to do this: Run the bookmarklet code through a URL decoder . so that javascript:alert%20('Hi%20Boss!')%3B , for example, becomes: javascript:alert ('Hi Boss!'); Strip the leading javascript: off. Result: alert ('Hi Boss!'); Add this code to the end of your Greasemonkey file. For example, create a file named, Hello World.user.js , with this code: // ==UserScript== // @name Hello World! // @description My first GM script from a bookmarklet // @include

jQuery.getJSON inside a greasemonkey user script

为君一笑 提交于 2019-11-28 06:04:06
I am attempting to write a user script that makes a cross domain AJAX request. I have included jQuery inside my script using @require and everything seems to be working fine up until the point where I try to run jQuery.getJSON. The API I am accessing supports jsonp, however I keep getting an error stating jsonp123456789 is not defined. From what I have been able to gather this is due to jQuery writing the jsonp response directly into the head of the page, which then becomes sandboxed. Once that has occured jQuery can no longer access the callback resulting in it being undefined. (I'm not 100%

Protect Greasemonkey scripts?

早过忘川 提交于 2019-11-28 06:03:04
问题 I know that anything that is downloaded and is in the user's possession is going to be pretty hard to protect, but I'm just wanting to hear opinions. I'm thinking of selling a script (made with Greasemonkey...), and I want to be able to prevent the user from easily viewing the source code, or sending it to others. Thanks in advance. 回答1: As with any javascript, complete protection is impossible due to the nature of the language, see: Javascript library: to obfuscate or not to obfuscate - that

Find all instances of 'old' in a webpage and replace each with 'new', using a javascript bookmarklet

不羁的心 提交于 2019-11-28 05:31:34
What I want to do is replace all instances of 'old' in a webpage with 'new' in a JS bookmarklet or a greasemonkey script. How can I do this? I suppose jQuery or other frameworks are okay, as there're hacks to include them in both bookmarklets as well as greasemonkey scripts. A function that is clobber-proof. That mean's this won't touch any tags or attributes, only text. function htmlreplace(a, b, element) { if (!element) element = document.body; var nodes = element.childNodes; for (var n=0; n<nodes.length; n++) { if (nodes[n].nodeType == Node.TEXT_NODE) { var r = new RegExp(a, 'gi'); nodes[n]

“Normal” button-clicking approaches are not working in Greasemonkey script?

ⅰ亾dé卋堺 提交于 2019-11-28 05:28:51
问题 Here is the button on the page: <a id="dispatchOnJobButton" class="ui-btn ui-btn-corner-all ui-shadow ui-btn-up-c" href="#" data-role="button" data-theme="c" data-disabled="false"> <span class="ui-btn-inner ui-btn-corner-all" aria-hidden="true"> <span class="ui-btn-text">Dispatch on next job</span> </span> </a> I need Greasemonkey to click it. I tried many different methods, but none seem to fire whatever function it is supposed to run. var clickEvent = document.createEvent("MouseEvents");