greasemonkey

How to access `window` (Target page) objects when @grant values are set?

亡梦爱人 提交于 2019-11-26 01:43:28
问题 Let\'s say I am working with the following web page: <html> <body> <span id=\"click\">click me</span> <script> var hello = function() { alert(\'hello\'); } document.getElementById(\'click\').addEventListener(\'click\', function(e) { hello(); }); </script> </body> </html> and my Greasemonkey script is: // ==UserScript== // @name My Script // @include http://example.com/hello.html // @version 1 // @grant none // ==/UserScript== window.hello = function() { alert(\'goodbye\'); } With the

Event when window.location.href changes

孤人 提交于 2019-11-26 01:07:44
问题 I\'m writing a Greasemonkey script for a site which at some point modifies location.href . How can I get an event (via window.addEventListener or something similar) when window.location.href changes on a page? I also need access to the DOM of the document pointing to the new/modified url. I\'ve seen other solutions which involve timeouts and polling, but I\'d like to avoid that if possible. 回答1: popstate event: The popstate event is fired when the active history entry changes. [...] The

How to get an AJAX get-request to wait for the page to be rendered before returning a response?

末鹿安然 提交于 2019-11-26 00:55:54
问题 I am in the process of writing a Greasemonkey Script for pages in this site (Site1). Site1 has deals and offers of various kinds and my GM script aims to do the following: When one visits an offer on Site1, the script queries Site2 to find out whether this hotel is also listed on Site2. If so, display the search results from Site2 on Site1. The problem is that Site2 displays a progress bar (\"Loading Results\") and then displays the results. Thus my Ajax request always returns empty results

My very simple Greasemonkey script is not running?

蓝咒 提交于 2019-11-26 00:34:21
问题 I am having issues with this very basic Greasemonkey script, most likely with the metadata configuration. Here is the full source of the basic file // ==UserScript== // @name Google Hello // @namespace https://google.com // @description Basic Google Hello // @include * // @version 1 // ==/UserScript== alert(\"hi google!\"); This script should run when I access Google.com, but the alert is not popping up. What is the issue? I am attempting to run this script on Ubuntu with Firefox. 回答1: If

jQuery in Greasemonkey 1.0 conflicts with websites using jQuery

故事扮演 提交于 2019-11-26 00:00:58
问题 Ever since the new Greasemonkey 1.0 was released a few days ago, every site that has jQuery and where I use jQuery in my Greasemonkey script do not run my script properly. The jQuery I have in my GS script (using the @require metadata) conflicts with the page\'s jQuery. This is due to the new @grant code. I\'ve read the documentation but still don\'t know how to run GS scripts in a sandbox again; the only options seem to be to either grant access to a GS API or to grant it to none and run the

Stop execution of Javascript function (client side) or tweak it

北城以北 提交于 2019-11-25 23:37:39
问题 I want to stop the execution of one single line from a site, so that the whole page is read by the browser except that single line. Or the browser may simply skip the execution of that javascript function. OR Is there way i can tweak the javascript somehow so that the random number generating function in javascript do not generate random number, but the numbers i want... I dont have access to the site on which the script is hosted so all this needs to be done client side. 回答1: Firefox

How can I use jQuery in Greasemonkey scripts in Google Chrome?

时光毁灭记忆、已成空白 提交于 2019-11-25 23:24:27
问题 As some of you may know, Google Chrome has put some severe limitation on Greasemonkey scripts. Chromium does not support @require , @resource , unsafeWindow , GM_registerMenuCommand , GM_setValue , or GM_getValue . Without require, I can\'t find a way to include the jQuery library in Greasemonkey script under Google Chrome. Does anybody have some advice in this matter? 回答1: From "User Script Tip: Using jQuery - Erik Vold's Blog" // ==UserScript== // @name jQuery For Chrome (A Cross Browser

How to access `window` (Target page) objects when @grant values are set?

蓝咒 提交于 2019-11-25 22:53:49
Let's say I am working with the following web page: <html> <body> <span id="click">click me</span> <script> var hello = function() { alert('hello'); } document.getElementById('click').addEventListener('click', function(e) { hello(); }); </script> </body> </html> and my Greasemonkey script is: // ==UserScript== // @name My Script // @include http://example.com/hello.html // @version 1 // @grant none // ==/UserScript== window.hello = function() { alert('goodbye'); } With the Greasemonkey script disabled, clicking the #click element on the page displays the 'hello' alert. With the script enabled,

Run Greasemonkey script on the same page, multiple times?

一世执手 提交于 2019-11-25 22:43:56
问题 I\'m totally new to Greasemonkey, javascript, in fact all the UI stuff. Requirement: Userscript is run by GS once after the page loads. However, I need the same script to be run multiple times without refresh Use case: For ex, Amazon.com search happens using Ajax. I need to embed a custom element in the search results. I need to inject my content to the search-results-div along with the results every time a search happens in the same page (there\'s no page refresh) My current script runs only

Accessing Variables from Greasemonkey to Page & vice versa

蓝咒 提交于 2019-11-25 22:29:11
I have the following code in test.js which is run right before </body>: alert('stovetop'); alert(greasy); I have the following code in test.user.js : (function () { 'use strict'; var greasy = 'greasy variable'; document.title = 'greasy title'; }()); 'stovetop' gets alerted so I know the page javascript works, and document.title gets changes so I know that the script javascript works. However, on the webpage I get the error: Error: ReferenceError: greasy is not defined Source File: /test.js How from the webpage do I access the variable set by Greasemonkey and how about vice versa? Brock Adams