Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger Tampermonkey/Greasemonkey userscript in Slack web verision?

I'm having trouble getting any userscript to execute in Slack web interface. The script is loaded with the page, as shown by Tampermonkey, but it doesn't even write into the console.

Even something totally basic like below has no effect.

// ==UserScript==
// @name         New Userscript
// @namespace    Namespace
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://app.slack.com/*
// @grant        none
// ==/UserScript==

(function() {
    console.log('==================');
})();

I tried to use waitForKeyElements but with no success. Is there a way around this?

EDIT: It appears to be a problem specifically with Firefox (101.0 (64-bit)) & Tampermonkey 4.17.6161, as Edge (Version 102.0.1245.33 (Official build) (64-bit)) & Tampermonkey 4.16.1 works fine with the same userscript.

like image 408
marioErr Avatar asked Dec 28 '25 21:12

marioErr


2 Answers

It appears to be a problem specifically with Firefox (101.0 (64-bit)) & Tampermonkey 4.17.6161, as Edge (Version 102.0.1245.33 (Official build) (64-bit)) & Tampermonkey 4.16.1 works fine with the same userscript. There are few variables here, but I consider this an answer to this question sufficient to my current needs.

like image 180
marioErr Avatar answered Dec 30 '25 22:12

marioErr


Okay, so letting you know that it worked for me. But there were many other lines that flooded the console (especially in a Slack channel), so I made sure the console log I added would be easy to notice. Here's what I added:

// ==UserScript==
// @name         ___NewUserscript
// @namespace    http://tampermonkey.net/
// @match        https://app.slack.com/*
// @grant        none
// ==/UserScript==

(function() {
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
console.log('**********************************************************************');
})();

In the console, my blocks of asterisks were added about 15 lines down, and then scads of lines appeared after that.

You are probably right that it's a Firefox problem - I tried my script with Brave browser (a secure variant of Chrome by the same guy who created Firefox) and it worked fine.

If that's the answer (i.e. Firefox vs Chrome/Edge), please add that as an answer and mark it as the correct answer in order to close out the question and make it easy for the next guy.

like image 36
cssyphus Avatar answered Dec 31 '25 00:12

cssyphus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!