Last active
August 5, 2024 11:58
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 Auto Close Slack Tab on Redirect | |
// @namespace https://*.slack.com/archives/* | |
// @version 0.3 | |
// @description Auto close Slack's "We’ve redirected you to the desktop app." tabs. | |
// @author Tim Kersten | |
// @match https://klarna.slack.com/archives/* | |
// @grant none | |
// @homepageURL https://gist.github.com/io41/304b1af0f83f82dd4408612b31bb25b5 | |
// @updateURL https://gist.github.com/io41/304b1af0f83f82dd4408612b31bb25b5/raw/auto-close-slack-tab-on-redirect.user.js | |
// @downloadURL https://gist.github.com/io41/304b1af0f83f82dd4408612b31bb25b5/raw/auto-close-slack-tab-on-redirect.user.js | |
// @license MIT | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// The text to search for | |
const redirectText = "We’ve redirected you to the desktop app."; | |
// Function to check for the redirect element | |
function checkForRedirect() { | |
const redirectElement = document.querySelector('p.p-ssb_redirect__loading_messages'); | |
if (redirectElement && redirectElement.innerText.includes(redirectText)) { | |
window.close(); | |
} | |
} | |
// Check for the element 2 seconds after loading | |
setTimeout(checkForRedirect, 2000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment