Greasy Fork is available in English.
全方位拦截,包括 JS 跳转扫描
当前为
// ==UserScript==
// @name Rickroll & Scam Detector (Ultra)
// @namespace http://tampermonkey.net/
// @version 1.4
// @description 全方位拦截,包括 JS 跳转扫描
// @author dext
// @match *://*/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @connect anti-rickroll.dext.top
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const API_ENDPOINT = "https://anti-rickroll.dext.top";
GM_addStyle(`
#rick-guard-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 2147483647; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(8px); }
.rick-modal { background: #fff; padding: 40px; border-radius: 20px; width: 350px; text-align: center; box-shadow: 0 25px 50px rgba(0,0,0,0.6); border: 4px solid #ff4444; }
.rick-modal h2 { color: #cc0000; font-size: 24px; margin-bottom: 15px; }
.rick-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.rick-btn { width: 100%; padding: 15px; border-radius: 10px; cursor: pointer; font-weight: bold; border: none; font-size: 16px; }
.btn-go { background: #ff4444; color: white; }
.btn-cancel { background: #eee; color: #333; }
#rick-scan-status { position: fixed; top: 10px; right: 10px; background: #000; color: #0f0; padding: 8px 15px; border-radius: 5px; font-family: monospace; font-size: 12px; z-index: 2147483646; display: none; border: 1px solid #0f0; }
`);
const statusEl = document.createElement('div');
statusEl.id = 'rick-scan-status';
document.body.appendChild(statusEl);
// 拦截全局点击
window.addEventListener('click', function(e) {
const a = e.target.closest('a');
if (!a || !a.href || a.dataset.rickSafe === '1' || a.href.startsWith('javascript:') || a.href.startsWith('#')) return;
e.preventDefault();
e.stopPropagation();
statusEl.innerText = "[CORE_SCANNING]: " + new URL(a.href).hostname;
statusEl.style.display = 'block';
GM_xmlhttpRequest({
method: "POST",
url: API_ENDPOINT,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ url: a.href }),
timeout: 10000,
onload: function(response) {
statusEl.style.display = 'none';
try {
const res = JSON.parse(response.responseText);
if (res.isRickroll) {
showWarning(a.href, a);
} else {
a.dataset.rickSafe = '1';
a.click();
}
} catch (err) {
a.dataset.rickSafe = '1'; a.click();
}
},
onerror: () => { statusEl.style.display = 'none'; a.dataset.rickSafe = '1'; a.click(); }
});
}, true);
function showWarning(url, originalElement) {
const overlay = document.createElement('div');
overlay.id = 'rick-guard-overlay';
overlay.innerHTML = `
<div class="rick-modal">
<div style="font-size: 60px;">🚨</div>
<h2>高度危险链接</h2>
<p>系统检测到该链接包含 <b>JavaScript 自动跳转</b> 或隐藏的 <b>Rickroll</b> 特征。访问此链接将 100% 触发恶意内容。</p>
<div class="rick-btns">
<button class="rick-btn btn-cancel" id="rick-cancel">立即拦截并关闭</button>
<button class="rick-btn btn-go" id="rick-ignore">我有心理准备,继续</button>
</div>
</div>
`;
document.body.appendChild(overlay);
document.getElementById('rick-cancel').onclick = () => overlay.remove();
document.getElementById('rick-ignore').onclick = () => {
overlay.remove();
originalElement.dataset.rickSafe = '1';
window.location.href = url;
};
}
})();