Greasy Fork is available in English.
8/17/25 Hide Unsafe Direct Download Links
当前为
// ==UserScript==
// @name Hide Unsafe Direct Download Links
// @namespace yyyzzz999
// @author yyyzzz999
// @description 8/17/25 Hide Unsafe Direct Download Links
// @match https://www.myanonamouse.net/tor/browse.php*
// @match https://www.myanonamouse.net/index.php
// @match https://www.myanonamouse.net/
// @version 2.0
// @icon https://www.myanonamouse.net/pic/smilies/MoreSmilies/jumping-smiley-002.gif
// @homepage http://greasyfork.icu/en/users/705546-yyyzzz999
// @license MIT
// @grant none
// ==/UserScript==
/*jshint esversion: 11 */
/*eslint no-multi-spaces:0 */
//TODO: Add a reminder near UTC midnight that some VIP or Site FL torrents may expire soon!
// Constants
var DEBUG = 0; // Verbose debugging mode on (1) or off (0)
const TblWait = 1500; // Timeout for table loading and processing
const SanityWindow = 800; // Sanity window in milliseconds avoids multiple table modifications
// Global variables
var modifyCount = 0;
var lastModifyTimestamp = null;
var lastProcessingTimestamp = null;
if (DEBUG > 0) console.log('Starting Hide Unsafe Direct Download Links');
// Function to modify the table
function modifyTable(table) {
const now = Date.now();
if (lastProcessingTimestamp && now - lastProcessingTimestamp < SanityWindow) {
if (DEBUG > 0) {
console.log(`[DEBUG] Skipping modifyTable - still within SanityWindow (${now - lastProcessingTimestamp}ms)`);
}
return; // Sanity check: Don't process if still within the wait time
}
lastProcessingTimestamp = now;
if (DEBUG > 0) {
console.log(`[DEBUG] Calling modifyTable at: ${now}`);
}
console.log('Modifying table:', table);
const rows = table.querySelectorAll('tr:nth-child(n+2)');
rows.forEach((row, index) => {
const col2 = row.cells[1];
const col4 = row.cells[3];
if (!col2 || !col4) return;
const hasValidImage = col2.querySelector('img[alt="VIP"], img[alt="freeleech"]');
const hasValidSpan = Array.from(col2.querySelectorAll('span')).some(span => span.textContent.trim() === "PF");
if (!hasValidImage && !hasValidSpan) {
const links = col4.querySelectorAll('a[title="Direct Download"]');
links.forEach(link => {
link.remove();
});
}
});
modifyCount++;
lastModifyTimestamp = now;
if (DEBUG > 0) {
console.log(`[DEBUG] Modified at: ${lastModifyTimestamp}`);
}
}
// Initial table modification
setTimeout(() => {
const table = document.querySelector('table.newTorTable');
if (table) {
//console.log('Starting Hide Unsafe Direct Download Links');
modifyTable(table);
if (DEBUG > 0) console.log('Hide Unsafe Direct Download Links removed fist batch');
} else {
console.log('Table not found. Skipping modification.');
}
}, TblWait);
// Mutation Observer
const observer = new MutationObserver(mutations => {
for (const mutation of mutations) {
// Check if any added nodes are tables with the class 'newTorTable'
const newTables = Array.from(mutation.addedNodes).filter(node => node.nodeType === Node.ELEMENT_NODE && node.classList.contains('newTorTable'));
for (const newTable of newTables) {
if (DEBUG > 0) {
console.log(`[DEBUG] Mutation Observer detected new table: ${newTable}`);
}
setTimeout(() => {
modifyTable(newTable);
}, TblWait);
}
}
});
const parentElement = document.getElementById('ssr');
if (parentElement) {
const config = { childList: true, subtree: true };
observer.observe(parentElement, config);
} else {
console.log('Parent element with ID "ssr" not found.');
}