tampermonkey

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

泪湿孤枕 提交于 2019-11-27 02:38:10
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, although it's not always reliable. What is the best technique to use in Greasemonkey to ensure that the

Redirect faster with Greasemonkey (or similar userscript engine)?

谁说胖子不能爱 提交于 2019-11-27 02:27:43
问题 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? 回答1: You can use

How to convert a bookmarklet into a Greasemonkey userscript?

空扰寡人 提交于 2019-11-27 02:00:16
问题 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? 回答1: 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: // =

Simulating a mousedown, click, mouseup sequence in Tampermonkey?

孤街浪徒 提交于 2019-11-27 00:19:36
I would like to simulate a whole click not just document.getElementsByClassName()[0].click(); How do I do that? Search results all seem to be about handling such events, not triggering them. Brock Adams Send mouse events. Like so: //--- Get the first link that has "stackoverflow" in its URL. var targetNode = document.querySelector ("a[href*='stackoverflow']"); if (targetNode) { //--- Simulate a natural mouse-click sequence. triggerMouseEvent (targetNode, "mouseover"); triggerMouseEvent (targetNode, "mousedown"); triggerMouseEvent (targetNode, "mouseup"); triggerMouseEvent (targetNode, "click")

How to replace lots of words in AJAX-driven page text, and in select attributes — using a Tampermonkey script?

我的梦境 提交于 2019-11-26 23:41:21
问题 I'm translating text/words/terms inside an HTML document using a tree walker to affect only text nodes: var replaceArry = [ [/View your user account/gi, 'Tu cuenta'], // etc. ]; var numTerms = replaceArry.length; var txtWalker = document.createTreeWalker ( document.body, NodeFilter.SHOW_TEXT, { acceptNode: function (node) { //-- Skip whitespace-only nodes if (node.nodeValue.trim() ) return NodeFilter.FILTER_ACCEPT; return NodeFilter.FILTER_SKIP; } }, false ); var txtNode = null; while

Synchronous GM_xmlhttpRequest acting asynchronously?

为君一笑 提交于 2019-11-26 23:39:34
问题 I'm trying to get a GM_xmlhttpRequest call to behave synchronously, but I can't get it to work like I expect: function myFunction (arg) { var a; GM_xmlhttpRequest ( { method: "GET", url: "http://example.com/sample/url", synchronous: true, onload: function (details) { a = details.responseText; } } ); return a; } b = myFunction (); alert (b); I never get anything back for b here; it's undefined. Is there some step that I'm missing here? I'm using v0.9.13 of Greasemonkey, and v9.0.1 of Firefox.

Add parameters to the URL (redirect) via a Greasemonkey/Tampermonkey/Userscript

陌路散爱 提交于 2019-11-26 23:08:25
I'd like to write a Greasemonkey/userscript that automatically adds .compact to URLs starting with https://pay.reddit.com/ so It automatically redirects me to the mobile version. I've been looking at similar userscripts, particularly this one: https://userscripts.org/scripts/review/112568 trying to figure out how to edit the replacement pattern, but I lack skills in this domain. How do I write a Greasemonkey script that redirects me from https://pay.reddit.com/* to https://pay.reddit.com/*.compact ? Thanks The script should do these things: Detect if the current URL is already to the compact

Controlling Netflix (HTML5) playback with Tampermonkey/javascript

狂风中的少年 提交于 2019-11-26 22:59:37
问题 While watching a netflix video on a Netflix site, my goal is to have a userscript invoke the playback controls programmatically. Specifically, the volume, level, play/pause state, and time position of the video. I've been able to manipulate the html5 video element itself, but controlling that directly does not provide the needed netflix control bar feedback to the user. (i.e. video is paused, but the control bar still shows it as playing). My approach thus far has been to try and locate the

Changing a page's URL parameters

我们两清 提交于 2019-11-26 22:09:45
问题 I want to add the parameter &vhs=1 at the end of each YouTube video URL on my browser. I have tried using the following script but it gets stuck in a loop (keeps adding &vhs=1 &vhs=1... ). // ==UserScript== // @name Youtube Tape Mode // @namespace _pc // @match *://*.youtube.com/watch?* // @run-at document-start // ==/UserScript== var oldUrlPath = window.location.pathname; /*--- Test that "&vhs=1" is at end of URL, excepting any "hashes" or searches. */ if ( ! /\&vhs=1$/.test (oldUrlPath) ) {

How to change a class CSS with a Greasemonkey/Tampermonkey script?

耗尽温柔 提交于 2019-11-26 22:06:38
I'm trying to set the background image of the body, but only where it uses the class banner_url . The HTML is as follows: <body id="app_body" class="banner_url desktopapp" data-backdrop-limit="1"> Basically, I would like to force the page to use the following CSS instead: .banner_url { background: url('http://www.pxleyes.com/images/contests/kiwis/fullsize/sourceimage.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } I am trying to do this using Greasemonkey if it makes any difference. Does