Slack auto-open link in browser

Automatically clicks the "open this link in your browser"

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Slack auto-open link in browser
// @namespace    Violentmonkey Scripts
// @version      1.0
// @description  Automatically clicks the "open this link in your browser" 
//				link in Slack/archives webpages
// @author      AdrianSkar
// @match        *://*.slack.com/archives/*
// @grant        none
// ==/UserScript==

(function () {
	'use strict';
	function clickLink() {
		const links = document.querySelectorAll('a');
		// Find target link by its text content
		for (let link of links) {
			if (link.textContent.includes("open this link in your browser")) {
				link.click();
				console.log('Auto-clicked link:', link.href);
				break; // Stop after clicking the first matching link
			}
		}
	}
	window.onload = function () {
		setTimeout(clickLink, 100); // Delay execution by Xms
	};
	// Optionally, if content might load dynamically even after window.onload,
	// you can set an interval to attempt clicking periodically
	// setInterval(clickLink, 5000); // Attempt to click every 5 seconds
})();