// ==UserScript== // @name 标签页面管理精简版 // @namespace https://viayoo.com/jcdamz // @description 管理链接跳转:默认内同外新,新标签白名单强制新开,禁新标列表强制同页,支持拦截劫持。 // @version 1.0 // @author Via & Gemini // @match *://*/* // @license MIT // @run-at document-start // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAYhSURBVHic7Z1fbBRVFMa/M7stFG1rhJq22y79C21FLQmlfbM8mGhiYl/UxJgI/onQRCw+4gPy4IO+IJAIRqVITEgMwWJixBAFLCnWLbYQoJUCaYGllUVot9Jut9s9Pixst9Kl2507e3fL+SXbzHTvfOfM/Wbm3pnJvQsIgiAIgiAIgiAIgiAIgiAIgiAIwnyGEhmsoKLm2UTGi5drPa7jiYplqQEFFavqDaKXCEYDCEVWxlIOo48RbAkyH7rW03HMqjCWGFBQsareRrYtINRboZ9wGMcmeXKrFUbYVAs6q1ZvMcjYm3JH/IMgFBlkrM3OcWDY41Z6eVJqgLOqthlMTSAGJbZ5sRwGA6D67JyComGP+5AqXWUGOKtqm4mxlghJWfnMAIgBjmNjCv2h0GK1ShOU1JSzsraJCNvurRcW5GPl0yuilj924iS83hEVoWOCme/WobndjdRhxqYr3e2fmc3NMCuQW1FXRIRtHHFkTUwEzMoqg5lBRKYrHwCICEyhs4kI23Ir6ky3c6azWlq5+nsQNYR3NIlgBgg8rfInSx1z1jHcHpDPH6Eb2ldm/uZK9x9rzeRoqsYcVTXVdhidkUnNhN2ehkBgwkyouPh/TmPrXkTwqdKYtn0+x4EnH80Or9vbzoBGRgEAR379DT0XLgEAxoNUPNjze1+8Odrj3RAAbGzUz2ahs6gMy6uqMeH349wZFzw3BsyEnBsRuU3mL4m58gHglVwnns+JOFuKq8KLlcvK0PjBhwCAdOIGAHG3BaYMIHDDbCdRSXko8bT0dDiLyxNrQCQZCwAAWfY0bC1/BoULH5l1k6P/DKLZfQmjkwGQ+wYWtLTi2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JhXMw0HmDVd7XHtVSSofOeeoqqm2s9ECgv7ZOlTC6A9QsEHVkX8Py4YuOitrmwj8UayNc9ISOuqbVB71kVg+djT0Iw62BgJXhyKam2XQcpiPAwCDuoI82WLljzcIgiAIgiAIgiAIgiAkmP8ABazsbkReAE4AAAAASUVORK5CYII= // @grant GM_setValue // @grant GM_getValue // @grant GM_setClipboard // @grant GM_registerMenuCommand // @downloadURL https://update.greasyfork.icu/scripts/575244/%E6%A0%87%E7%AD%BE%E9%A1%B5%E9%9D%A2%E7%AE%A1%E7%90%86%E7%B2%BE%E7%AE%80%E7%89%88.user.js // @updateURL https://update.greasyfork.icu/scripts/575244/%E6%A0%87%E7%AD%BE%E9%A1%B5%E9%9D%A2%E7%AE%A1%E7%90%86%E7%B2%BE%E7%AE%80%E7%89%88.meta.js // ==/UserScript== (function() { 'use strict'; const KEY = 'page_manager_configs'; const defaultSettings = { activeTab: 1, newTab: { enabled: true, list: '', stopProp: 'off', stopList: '' }, removeNewTab: { enabled: true, list: '' } }; let settings = GM_getValue(KEY, defaultSettings); settings = { ...defaultSettings, ...settings, newTab: { ...defaultSettings.newTab, ...settings.newTab }, removeNewTab: { ...defaultSettings.removeNewTab, ...settings.removeNewTab } }; const currentHost = location.hostname; let shadowRoot = null; const isInternalLink = (url) => { try { const targetHost = new URL(url, document.baseURI || location.href).hostname; return targetHost === location.hostname; } catch (e) { return true; } }; const checkMatch = (listStr) => { const currentUrl = location.href; const lines = listStr.split('\n').map(l => l.trim()).filter(Boolean); for (let line of lines) { try { if (line.startsWith('/') && line.lastIndexOf('/') > 0) { const lastSlashIndex = line.lastIndexOf('/'); const regex = new RegExp(line.slice(1, lastSlashIndex), line.slice(lastSlashIndex + 1)); if (regex.test(currentUrl)) return true; } else if (currentUrl.includes(line)) return true; } catch (e) {} } return false; }; window.addEventListener('click', (e) => { const link = e.target.closest('a'); if (!link || !link.href || !/^https?:\/\//i.test(link.href)) return; const isInternal = isInternalLink(link.href); const forceNew = checkMatch(settings.newTab.list); const forceSame = checkMatch(settings.removeNewTab.list); if (forceSame) { if (link.target === '_blank') link.removeAttribute('target'); } else if (forceNew || !isInternal) { e.preventDefault(); window.open(link.href, '_blank'); const nT = settings.newTab; const isStopMatched = (nT.stopList || '').split('\n').includes(currentHost); if (nT.stopProp === 'all' || (nT.stopProp === 'match' && forceNew && isStopMatched)) { e.stopPropagation(); } } else if (isInternal) { if (link.target === '_blank') link.removeAttribute('target'); if (e.ctrlKey || e.metaKey) { e.preventDefault(); location.href = link.href; } } }, true); const setClipboard = (text, successCallback) => { const done = () => { if (successCallback) successCallback(); else alert('已复制'); }; if (typeof GM_setClipboard !== 'undefined') { GM_setClipboard(text); done(); } else { const tx = document.createElement("textarea"); tx.value = text; tx.style.position = "fixed"; tx.style.left = "-9999px"; document.body.appendChild(tx); tx.select(); try { document.execCommand('copy'); done(); } catch (err) {} document.body.removeChild(tx); } }; function createUI() { if (shadowRoot) return; const container = document.createElement('div'); container.style.cssText = 'position:fixed;top:0;left:0;z-index:2147483647;'; document.documentElement.appendChild(container); shadowRoot = container.attachShadow({ mode: 'closed' }); const style = document.createElement('style'); style.textContent = ` .mask { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.4); backdrop-filter:blur(10px); display:flex; align-items:center; justify-content:center; animation: fade 0.3s; font-family:system-ui,-apple-system; } .panel { background:rgba(255,255,255,0.9); width:340px; border-radius:30px; padding:20px; box-shadow:0 20px 40px rgba(0,0,0,0.2); position:relative; } .header { margin-bottom: 15px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.05); } .domain { font-size: 18px; font-weight: 700; color: #1C2526; } .url-bar { position: relative; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.03); padding: 6px 10px; border-radius: 10px; margin-top:8px; } .url-text { font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; flex: 1; } .copy-btn { font-size: 10px; background: #fff; border: 1px solid #ddd; padding: 2px 6px; border-radius: 6px; cursor: pointer; color: #007AFF; } .copy-menu { position: absolute; right: 0; top: 0; bottom: 0; background: #fff; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 10px; transform: translateX(100%); opacity: 0; pointer-events: none; transition: 0.3s; z-index: 3; box-shadow: -10px 0 15px rgba(0,0,0,0.05); } .copy-menu.show { transform: translateX(0); opacity: 1; pointer-events: auto; } .menu-item { font-size: 10px; padding: 4px 8px; border-radius: 6px; cursor: pointer; background: #f0f0f0; border: none; } .nav { display:flex; gap:5px; margin-bottom:15px; background:rgba(0,0,0,0.05); padding:5px; border-radius:15px; } .nav-item { flex:1; padding:8px; text-align:center; font-size:11px; cursor:pointer; border-radius:10px; transition:0.3s; font-weight:600; color:#666; } .nav-item.active { background:#fff; color:#007AFF; box-shadow:0 2px 8px rgba(0,0,0,0.1); } .section { display:none; flex-direction:column; gap:12px; animation: slide 0.3s; } .section.active { display:flex; } .row { display:flex; justify-content:space-between; align-items:center; } .label { font-size:13px; font-weight:600; color:#333; } .switch-group { display:flex; gap:4px; background: rgba(0,0,0,0.05); padding: 3px; border-radius: 10px; } .btn { border:none; padding:5px 9px; border-radius:7px; cursor:pointer; font-size:10px; background:transparent; color: #555; } .btn.active { background:#fff; color:#007AFF !important; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } .btn-group { display:flex; gap:8px; margin-top:8px; } textarea { width:100%; height:110px; border-radius:12px; border:1px solid #ddd; padding:10px; box-sizing:border-box; font-family:monospace; font-size:11px; resize:none; } .save-btn { width:100%; background:#007AFF; color:#fff; border:none; padding:12px; border-radius:15px; font-weight:bold; cursor:pointer; margin-top:15px; } @keyframes fade { from { opacity:0; } to { opacity:1; } } @keyframes slide { from { transform:translateX(10px); opacity:0; } to { transform:translateX(0); opacity:1; } } @media (prefers-color-scheme: dark) { .panel { background:rgba(30,30,30,0.9); color:#fff; } .label, .domain { color:#ddd; } textarea { background:#222; border-color:#444; color:#eee; } .nav-item.active { background:#444; color:#0A84FF; } .url-bar { background: rgba(255,255,255,0.05); } .copy-btn { background: #333; border-color: #555; } .copy-menu { background: #2c2c2e; } .menu-item { background: #3a3a3c; color: #eee; } .btn.active { background:#444; color:#0A84FF !important; } } `; shadowRoot.appendChild(style); const mask = document.createElement('div'); mask.className = 'mask'; const panel = document.createElement('div'); panel.className = 'panel'; const render = () => { const nT = settings.newTab; const isStopMatched = (nT.stopList || '').split('\n').includes(currentHost); panel.innerHTML = `