greasemonkey

I have to refresh the page for my Greasemonkey script to run?

寵の児 提交于 2019-11-26 14:39:21
问题 So I know it's something to do with AJAX, but I've read a few topics and don't quite understand what I have to do. Currently everything works fine, but I have to refresh the page for my script to run. What needs to be done with my code to get it working without refresh? // ==UserScript== // @name Job Aids // @description Aid in closing tickets // @include https://techaccess.ad.qintra.com/WorkJobs/WorkJobs.aspx* // @namespace camzilla.net // @version 1.1.20121128 // ==/UserScript== var url =

How can I intercept XMLHttpRequests from a Greasemonkey script?

主宰稳场 提交于 2019-11-26 14:17:32
I would like to capture the contents of AJAX requests using Greasemonkey. Does anybody know how to do this? 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! How about modifying the XMLHttpRequest

Add a JavaScript button using Greasemonkey or Tampermonkey?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 13:19:37
问题 I am fairly new to the world of Greasemonkey and I was wondering how to make a button in JavaScript. Say I wanted to put a button on YouTube or Google for instance? How would I go about calling it or making it? I'm very confused and cant find anything on it. Unless is there someway to interact with the HTML of these sites and add them to Greasemonkey scripts? 回答1: Ok, here's a complete script that adds a live button to SO question pages 1 : // ==UserScript== // @name _Adding a live button //

Detect iFrame embedding in Javascript

和自甴很熟 提交于 2019-11-26 13:00:51
I have an application that has a certain page -- let's call it Page A. Page A is sometimes a top-level page, but also sometimes is embedded as an iframe within page B. All pages come from the same server and there are no cross-domain issues. I have a greasemonkey script that runs on page A. How can the greasemonkey script detect whether page A is within the iframe context or not? Looking at frame length breaks down generally if page A itself has frames (I know this might not be the case for this specific instance). The more reliable and meaningful test would be: if (window!=window.top) { /* I

Detecting combination keypresses (Control, Alt, Shift)?

瘦欲@ 提交于 2019-11-26 12:40:20
问题 I am trying to make a script run when Ctrl + Alt + e is pressed. How can Tampermonkey fire on a simultaneous ctrl, alt, and e key? I have tried ctrlKey , and altKey . I\'ve found nothing that works. How can I edit the script below to fire on Ctrl + Alt + e , instead of just e ? (function() { document.addEventListener(\"keypress\", function(e) { if (e.which == 101) { var xhttp = new XMLHttpRequest; xhttp.onreadystatechange = function() { 4 == xhttp.readyState && 200 == xhttp.status && eval

How do I click on this button with Greasemonkey?

被刻印的时光 ゝ 提交于 2019-11-26 12:33:00
问题 I\'m a total newbie with JS, and I\'m trying to click on this button: <a class=\"simplebutton\" href=\"javascript:void(0);\">find</a> The XPath of this button is: /html/body/div[5]/div/span[2]/a , and a snapshot of the target page can be seen at this Fiddle. This is what I\'ve tried, but it doesn\'t work. (I\'m using the function getElementsByClassName which I got from http://code.google.com/p/getelementsbyclassname/): document.getElementsByClassName(\'simplebutton\').submit(); 回答1: Here is a

Userscript to wait for page to load before executing code techniques?

∥☆過路亽.° 提交于 2019-11-26 12:18:11
问题 I\'m writing a Greasemonkey user script, and want the specific code to execute when the page completely finishes loading since it returns a div count that I want to be displayed. The problem is, that this particular page sometimes takes a bit before everything loads. I\'ve tried, document $(function() { }); and $(window).load(function(){ }); wrappers. However, none seem to work for me, though I might be applying them wrong. Best I can do is use a setTimeout(function() { }, 600); which works,

How to debug Greasemonkey script with the Firebug extension?

无人久伴 提交于 2019-11-26 12:08:33
问题 I didn\'t find a way to debug Greasemonkey scripts with the Firebug extension. Does anyone know how to do this ? Thanks. 回答1: 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

How do I get the information from a meta tag with JavaScript?

大兔子大兔子 提交于 2019-11-26 11:39:49
The information I need is in a meta tag. How can I access the "content" data of the meta tag when property="video" ? HTML: <meta property="video" content="http://video.com/video33353.mp4" /> Saket You can use this: function getMeta(metaName) { const metas = document.getElementsByTagName('meta'); for (let i = 0; i < metas.length; i++) { if (metas[i].getAttribute('name') === metaName) { return metas[i].getAttribute('content'); } } return ''; } console.log(getMeta('video')); joepio The other answers should probably do the trick, but this one is simpler and does not require jQuery: document.head

How do I get Greasemonkey to click on a button that only appears after a delay?

送分小仙女□ 提交于 2019-11-26 11:28:17
问题 I\'ve seen a lot of similar questions and I\'ve tried everything I can think of to get this to work on my own. First the relevant code (¿from the target page?): document.getElementById(\'btn_submit\').innerHTML = \'<input type=\"hidden\" value=\"17271\" name=\"idofclick\"> <input type=\"submit\" value=\" Click Me Now! \" name=\"submit_com\" class=\"padding2\">\'; Basically there is a timer on the page and the \"click me now!\" button appears after 3 secs, that\'s the part I want to click on.