greasemonkey

How to make a script redirect only once every time an appropriate page loads?

我只是一个虾纸丫 提交于 2019-11-30 09:45:37
问题 I'm writing a Tampermonkey script that I want to use to redirect from youtube.com/* to a YouTube channel address. window.addEventListener ("load", LocalMain, false); function LocalMain () { location.replace("https://www.youtube.com/channel/*"); } When the script is running it redirects to the channel URL but then keeps running and continuously redirects . 回答1: You need to check if the current pathname includes channel before reassigning a new href function LocalMain () { if(!location.pathname

GreaseMonkey countdown not working?

孤人 提交于 2019-11-30 09:38:38
问题 I'm very confused, with greasemonkey setTimeout just isn't working, it never calls the function, looking online people say greasemonkey doesn't support setTimeout, is there anyway to make my objective (below) work? function countdown(time, id) { if(document.getElementById(id)) { var name = document.getElementById(id); var hrs = Math.floor(time / 3600); var minutes = Math.floor((time - (hrs * 3600)) / 60); var seconds = Math.floor(time - (hrs * 3600) - minutes * 60); if(hrs>0) { name.innerhtml

Replace array-mapped variables with the actual variable name/string?

半城伤御伤魂 提交于 2019-11-30 09:31:47
I am trying to edit a Greasemonkey/jQuery script. I can't post the link here. The code is obfuscated and compressed with minify. It starts like this: var _0x21e9 = ["\x67\x65\x74\x4D\x6F\x6E\x74\x68", "\x67\x65\x74\x55\x54\x43\x44\x61\x74\x65", ... After "decoding" it, I got this: var _0x21e9=["getMonth","getUTCDate","getFullYear", ... It is a huge list (500+ ). Then, it has some variables like this: month = date[_0x21e9[0]](), day = date[_0x21e9[1]](), ... _0x21e9[0] is getMonth, _0x21e9[1] is getUTCDate, etc. Is it possible to replace the square brackets with the actual variable name? How? I

How to correctly work on a GreaseMonkey userscript using git?

好久不见. 提交于 2019-11-30 09:26:52
I am working on a userscript for Firefox, so I use GreaseMonkey . Moreover, to facilitate the development, I use git to update the different versions of my code. Now, let me try to explain the issue. When I add to GreaseMonkey the userscript from my local git directory, then new files are created in the gm_scripts folder of my Firefox profile. GreaseMonkey use these files as source and not my git directory, so if I want to modify my code and test some stuff, I have to change the files inside the gm_scripts. This means that I can not commit the modification, I first have to copy the files from

Why doesn't my jQuery-UI script execute in Greasemonkey? It runs in the Firebug console

痴心易碎 提交于 2019-11-30 09:26:28
问题 I have tried quite a bit of research on this because this is my first Greasemonkey script: // ==UserScript== // @name Codecademy Resizeable Code // @description Adds jQuery resizable to editor // @namespace http://chrisneetz.com // @include http://www.codecademy.com/courses/* // ==/UserScript== $('#editor').resizable({ alsoResize: ".ace_scroller, .ace_editor, .ace_content, .ace_sb, .ace_print_margin_layer", handles: "n, s" }); I have tried Greasemonkey's recommendations and I'm not sure if it

userscript - Add item to right-click menu

本秂侑毒 提交于 2019-11-30 08:59:35
I am writing a userscript for Greasemonkey and want to add an item to right click context menu. If I'm not mistaken, this function is called window.addEventListener("contextmenu", ...) . Can you give me example of this? Following script was copied from http://userscripts-mirror.org/scripts/review/151097 : Important warning! This copy is unchanged and untested. There might be security issues with userscripts. GM is very powerful and if used on the wrong page the safety of your computer may be at risk. /* Google Image Search Context Menu Add 'Search by Image' in browser context menu when you

XPath or querySelector?

会有一股神秘感。 提交于 2019-11-30 08:56:18
XPath can do everything querySelector can do, and more, so when would you ever choose the latter? I haven't seen any speed benchmarks comparing the two, so right now I'm choosing based on syntax conciseness, which seems kind of arbitrary. Edit: I probably should have stated that I'm writing Greasemonkey scripts for Firefox, so I'm not worried about cross-browser compatibility, and would rather not include any libraries. Yehuda Katz What browser are you using? In Safari (or the iPhone), querySelector and querySelectorAll are much faster than XPath. IE doesn't support XPath at all, and IE6 and

Find and replace in a webpage using javascript [duplicate]

瘦欲@ 提交于 2019-11-30 08:45:28
问题 This question already has an answer here : Replace many text terms, using Tampermonkey, without affecting URLs and not looking for classes or ids (1 answer) Closed 2 years ago . What I want to do is replace all instances of 'foo' in a webpage with 'bar' in a JS bookmarklet/greasemonkey script. How can I do this? I suppose jQuery works, as there're hacks to include those in both bookmarklets and greasemonkey scripts. 回答1: This script iterates through each element in the document and replaces

Get if browser is busy

余生颓废 提交于 2019-11-30 08:42:28
问题 I'm trying to find a way to get if the browser is currently busy from JavaScript. I'm looking at making a Firefox extension to inject a Boolean value or something if the current page is loading something (either through ajax or just normal page loads), or the same with a Greasemonkey script, or through some JavaScript API (this would be the best solution, but from what I can see, nothing of the sort exists). I was wondering what the best way to do this would be. I've been looking for Firefox

Why isn't my Greasemonkey script updating?

冷暖自知 提交于 2019-11-30 08:12:58
I've got a Greasemonkey script for Firefox. The script includes this meta-block and some lines of code. I want to update my script on the server and then automatically update the browser's scripts. The requireSecureUpdates option is off. What am I doing wrong? My 1.meta.js // ==UserScript== // @name Ibood autosubmit // @include https://*.ibood.com/* // @include http://*.ibood.com/* // @include * // @version 1.1 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @grant GM_addStyle // @downloadURL http://www.tipsvoorbesparen.nl/1.user.js // @updateURL http://www