greasemonkey

How can I create an object of a class which is defined in the remote page?

房东的猫 提交于 2019-12-04 13:02:16
For example, in the remote webpage, there is a snippet of code like this: <script> function foo(){ this.bar = 0; } In my greasemonkey script, I want to create an object of this class: var _foo= unsafeWindow['foo']; new _foo(); Then I got an Illegal Value error. Here's how to do it: var _foo = eval('(' + unsafeWindow.foo.toSource() + ')'); var x = new _foo(); This workaround may be required due to the different security zones or sandboxing that Greasemonkey does, though I'm not entirely sure. 来源: https://stackoverflow.com/questions/535959/how-can-i-create-an-object-of-a-class-which-is-defined

Userscript to bypass same-origin policy for accessing nested iframes

雨燕双飞 提交于 2019-12-04 12:17:22
In the following HTML mockup, the nested iframes are originating from different subdomains. This is causing messages such as error: Permission denied to access property "document" <html> <head> <title></title> </head> <body> <div> <iframe id="outer_iframe_1" src="https://subdomain1.example.com"></iframe> </div> <div> <iframe id="outer_iframe_2" src="https://subdomain2.example.com"> <div> <iframe id="inner_iframe_2" src="https://subdomain4.example.com"></iframe> </div> </iframe> </div> <div> <iframe id="outer_iframe_3" src="https://subdomain3.example.com"></iframe> </div> </body> </html> I am

How to monitor a static HTML page for changes with Greasemonkey? Use a hash?

瘦欲@ 提交于 2019-12-04 12:05:36
I want my Greasemonkey script to run ONLY when the static page it's accessing has the exact same content as before... Now I have the ability to set a variable containing a hash of this page. I'm looking for a way to hash the page on the fly, so that I can compare my hash to the generated hash... Any ideas on how to accomplish this, on the fly, hashing? Brock Adams From your question: I want my Greasemonkey script to run ONLY when the static page it's accessing has the exact same content as before... What you really want is for your script to detect page changes. A hash is not normally the best

Greasemonkey against an iframe using @include - does this work? [duplicate]

女生的网名这么多〃 提交于 2019-12-04 11:40:45
问题 This question already has answers here : Apply a Greasemonkey/Tampermonkey/userscript to an iframe? (3 answers) Closed last year . I'm wondering if you can have Greasemonkey execute against an iframe only and not it's parent window. The parent window is domain A, the iframe is domain B, and the include in the script would be @include http://domain-B.com/path/*. I don't need any interaction with the parent. I've tried this a couple of times without success. Is there any cross-domain

Userscript to click button

青春壹個敷衍的年華 提交于 2019-12-04 10:44:05
I would like to click a buy now button using greasemonkey. // ==UserScript== // @name script // @namespace sc // @include * // @version 1 // @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== waitForKeyElements ("#buy-now", triggerMostButtons); function triggerMostButtons (jNode) { triggerMouseEvent (jNode[0], "mouseover"); triggerMouseEvent (jNode[0], "mousedown"); triggerMouseEvent (jNode[0], "click"); triggerMouseEvent (jNode[0], "mouseup"); } function

Programmatically fill reactjs form

爱⌒轻易说出口 提交于 2019-12-04 10:18:42
I am writing an userscript and I can't manage to fill a form made by reactjs. My code: document.querySelector("#id-username").value = "name@domain.xx"; // Attempt to notify framework using input event document.querySelector("#id-username").dispatchEvent(new Event("input", {data:"name@domain.xx"})); // Attempt to notify framework using change event document.querySelector("#id-username").dispatchEvent(new Event("change")); // This doesn't help either document.querySelector("#id-username").dispatchEvent(new Event("blur")); // Submit the form using button (it's AJAX form) document.querySelector(

How do I use constructor of a remote Page to create an Object in my Greasemonkey UserScript?

你。 提交于 2019-12-04 08:43:30
The page on which my userscript will run has a namespace, the namespace defines a constructor function. I would like to create an object using the same constructor and use methods of the object in my userscript. So far I have been unsuccessful. Here's what I am trying to do. The Page has the following native javascript block : var namespace={ constructor : function(){ this.sum = function(value1,value2){ alert(value1+value2); } } } being used like: var pageObject=new namespace.constructor(); pageObject.sum(1,2); In My Userscript its my intention to create an object just like pageObject and call

What is Greasemonkey/Tampermonkey doing to my jQuery object when I use GM_setValue?

我的未来我决定 提交于 2019-12-04 06:25:32
问题 I'm trying to select DOM elements into a Tampermonkey variable using GM_setValue , for later injection on different pages. I've created an example where I can do this in normal jQuery using .clone() , but when I set it as a value in Tampermonkey, it changes the value of the saved variable. Here's an HTML page to test the script on: <!DOCTYPE html> <html><head> <script data-require="jquery@*" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>

Trying to keep track of number of outstanding AJAX requests in firefox

回眸只為那壹抹淺笑 提交于 2019-12-04 05:35:55
I am using Selenium to test a web application and am not allowed to modify the application's javascript code. I am trying to track the number of outstanding AJAX requests by using GreaseMonkey to override XMLHttpRequest.send. The new send() will basically wrap what was set as the onreadystatechange callback, check the readyState, incrementing or decrementing the counter as appropriate, and calling the original callback function. The problem that I'm having appears to be a privilege issue because if I just browse to a page in a normal firefox browser, open firebug and paste in the following

Pass a variable to new page

隐身守侯 提交于 2019-12-04 05:35:40
问题 I am trying to pass a variable from one page, load another and enter that information. something Like this: When 127.0.0.1/test.html&ID=1234 location.href = "127.0.0.1/newpage.html" if (location.href == newpage.html){ var e = document.GetElementById("Loginbx"); e.Value = ID } I don't have access to modify 127.0.0.1/test.html nor newpage.html but would like to pass variables to them from another. Is this possible? 回答1: You could pass the values on the query string and then read those: location