// ==UserScript==
// @name Use page URL or Domain as Tab Title
// @version 1.2
// @description Set initial tab name to page URL (/domain) and recheck every N milliseconds
// @author Blindspots https://superuser.com/users/1007040/blindspots
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// get URL: 'window.location.host';
// get Domain: 'window.location.host';
const ref = window.location.href; // URL
const interval = 1000; // milliseconds
// Set initial document title to 'ref'
document.title = ref;
// Check for rewritten title every second
setInterval(() => {
if (document.title !== ref) {
document.title = ref;
}
}, interval);
})();
这是我编写的用户脚本,可以在用户脚本管理器(例如 Tampermoney(Edge 附加组件| Chrome 网上应用店))中使用。
它改变
document.title
元素以匹配页面的 URL 或域。如果您想从脚本中排除域或 URL,您可以添加一个
@exclude
参数。例如,要将脚本应用于每个页面但排除域
chatgpt.com
,您可以@match
像@exclude
这样使用: