greasemonkey-4

How do I run code on DOM ready in Greasemonkey 4?

心已入冬 提交于 2019-12-06 03:47:14
问题 With the update to Firefox 57 and Greasemonkey 4 a number of my userscripts broke. In some scripts I used: document.addEventListener('DOMContentLoaded', doStuff, false); This no longer works in Greasemonkey. What is the proper way to add an DOMContentLoaded event now? P.S. I checked that at the time of registering the event, DOM is still not ready. 回答1: I ran into a similar problem after GreaseMonkey upgraded to version 4, but I used addEventListener("DOMContentLoaded", function(){ // … });

Is the Immediately-Invoked Function Expression (IIFE) pattern really necessary when writing userscripts?

依然范特西╮ 提交于 2019-12-05 18:36:23
My question is quite similar to What is the purpose of a self executing function in javascript? , however it concerns userscripts (specifically for GreaseMonkey) instead. I see that some userscripts are distributed with this pattern, and some are not. Example of script with the IIFE pattern: (source) // ==UserScript== // (...) // ==/UserScript== (function(){ // if <condition> document.location.href += '?sk=h_chr'; // ... })(); Example of script without it: (source) // ==UserScript== // (...) // ==/UserScript== window.location.href = "https://www.facebook.com/?sk=h_chr"; In addition, I also

Greasemonkey script folder missing

对着背影说爱祢 提交于 2019-11-30 20:46:37
I am following the instructions to transfer Greasemonkey scripts to Tampermonkey: How to Transfer All Greasemonkey userscripts to Tampermonkey on Firefox 57+ . However the folder "gm_scripts" mentioned in the instructions does not exist on my PC. Here are the folders that I do have (Click for larger view): Would you know which of these the scripts may be in? I am a beginner at using scripts and maybe this is not really necessary, but it is good practice for me. Apparently GreaseMonkey no longer stores the user scripts in gm_scripts for Firefox. I have Firefox 58 with GreaseMonkey 4.2 . I

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 script folder missing

爷,独闯天下 提交于 2019-11-30 04:49:40
问题 I am following the instructions to transfer Greasemonkey scripts to Tampermonkey: How to Transfer All Greasemonkey userscripts to Tampermonkey on Firefox 57+. However the folder "gm_scripts" mentioned in the instructions does not exist on my PC. Here are the folders that I do have (Click for larger view): Would you know which of these the scripts may be in? I am a beginner at using scripts and maybe this is not really necessary, but it is good practice for me. 回答1: Apparently GreaseMonkey no

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

岁酱吖の 提交于 2019-11-29 16:50:44
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 . You need to check if the current pathname includes channel before reassigning a new href function LocalMain () { if(!location.pathname.includes('/channel/')) { location.replace("https://www.youtube.com/channel/*"); } } Also note you don't

How to Transfer All Greasemonkey userscripts to Tampermonkey on Firefox 57+

只愿长相守 提交于 2019-11-28 23:43:29
After read that Greasemonkey recommends users to install Tampermonkey or Violentmonkey . I've installed Tampermonkey and now I'm trying to transfer all my Greasemonkey 3.x scripts to be opened on Tampermonkey, but I can't find it's location or even how to do it. I've read this question that says where and how it's located on Chrome , but where is it on Firefox 57+? How can I transfer it? PS: I'm expecting I won't need to update every userscript I have. Based on derjanb comment I'm answering the question showing the steps I took to achieve the transfer of the userscripts. Enter about:support on