- Install one of these extensions you like in order to execute UserScript.
- Violentmonkey (FLOSS; Chrome/Firefox/Edge)
- Tampermonkey (Proprietary; Chrome/Firefox/Edge)
- Greasemonkey (FLOSS; Firefox)
- Open https://gist.github.com/mohno007/2622041668bbf4785b03a9072e59414a/raw/slack_permalink_auto_redirect.user.js
Last active
January 18, 2022 03:37
-
-
Save mohno007/2622041668bbf4785b03a9072e59414a to your computer and use it in GitHub Desktop.
Open a Slack permalink automatically; not open in Slack App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Slack Permalink Auto Redirect | |
// @namespace mohno007.github.io/slack-auto-redirect | |
// @version 1.0.2 | |
// @description Open a Slack permalink automatically; not open in Slack App | |
// @author mohno007 | |
// @match https://*.slack.com/archives/* | |
// @match https://*.slack.com/files/* | |
// @grant none | |
// @run-at document-end | |
// @updateURL https://gist.github.com/mohno007/2622041668bbf4785b03a9072e59414a/raw/slack_permalink_auto_redirect.user.js | |
// @downloadURL https://gist.github.com/mohno007/2622041668bbf4785b03a9072e59414a/raw/slack_permalink_auto_redirect.user.js | |
// ==/UserScript== | |
{ | |
const MaxTime = 5000; | |
const IntervalTime = 500; | |
let count = 0; | |
const intervalId = setInterval(() => { | |
const elem = document.querySelector('.fallback > a') || document.querySelector('a[href^="/messages/"]'); | |
if ((IntervalTime * count) > MaxTime) { | |
clearInterval(intervalId); | |
} | |
if (elem !== null) { | |
clearInterval(intervalId); | |
elem.click(); | |
} | |
count++; | |
}, IntervalTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment