您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Redirects Avistaz profiles to a specific URL
当前为
// ==UserScript== // @name Redirect Avistaz Profile // @namespace http://your-namespace.com // @version 1.0 // @description Redirects Avistaz profiles to a specific URL // @author Your Name // @match https://avistaz.to/profile/*/history // @match https://avistaz.to/profile/*/history* // @grant none // @run-at document-end // ==/UserScript== (function() { // Your existing code here function getUsernameFromURL() { const urlParts = window.location.href.split('/'); const usernameIndex = urlParts.indexOf('profile') + 1; if (usernameIndex < urlParts.length) { return urlParts[usernameIndex]; } return null; // Return null if username is not found } function buildRedirectURL(username) { return `https://avistaz.to/profile/${username}/history?order=active&sort=desc`; } function redirectIfMatch() { const username = getUsernameFromURL(); if (username) { const redirectURL = buildRedirectURL(username); if (window.location.href !== redirectURL) { window.location.href = redirectURL; } } } // Call the function to check and potentially redirect redirectIfMatch(); function replaceTable() { const table = document.querySelector("table"); // Assuming there's only one table const rows = table.querySelectorAll("tr"); const columnNames = ["Title","Active","100% Download","Seeders","Leechers","Completed","FileSize", "Upload","Download","Ratio","Hours to seed","Hours seeded","Finished?"]; const newData = []; for (let i = 1; i < rows.length; i++) { // Start from index 1 to skip the header row const cells = rows[i].querySelectorAll("td"); const Title = cells[1].querySelector('.torrent-filename').getAttribute('data-original-title'); const Href = cells[1].querySelector('.torrent-filename').getAttribute('href'); const Active = cells[3].textContent; const Completed = cells[4].textContent; const Seeders = cells[1].querySelector('.fa-arrow-up.text-green').textContent; const Leechers = cells[1].querySelector('.text-red').textContent; const CompletedNr = cells[1].querySelector('.text-blue').textContent; const rawFilesize = cells[1].querySelector('.text-orange').textContent; const Filesize= rawFilesize.match(/\d+(\.\d+)?/g); const rawDownload = cells[6].querySelector('.text-red').textContent; const Download = rawDownload.match(/\d+(\.\d+)?/g); const rawUpload = cells[5].querySelector('.text-green').textContent; const Upload = rawUpload.match(/\d+(\.\d+)?/g); // const Progress = cells[2].querySelector('.progress-bar').textContent; const Ratio = cells[7].querySelector('.text-bold').textContent; const Seededtimeraw=cells[10].querySelector('span').getAttribute('data-original-title') const reggy = /(\d+(\.\d+)?)/g; const Seedingtimeraw= Seededtimeraw.match(reggy); const intSeed = parseInt(Seedingtimeraw); console.log(intSeed) const Seedingtime=Math.ceil(intSeed/60); console.log(Seedingtime); var regex=/(\d+(\.\d+)?)\s*(GB|MB|KB|TB|B)\b/i; var match = rawDownload.match(regex); if (match == null) { match = "0"; } else { var value = parseFloat(match[1]); var unit = match[3]; if (unit === "GB") { value = value; } else if (unit === "TB") { value = value * 1024; } else if (unit === "KB") { value = value / 1024 / 1024; } else if (unit === "MB") { value = value / 1024; } } var roundedNumber3 = value; unit=match[3]; if (roundedNumber3===0) { result="0" } else if (roundedNumber3 <= 1) { result = 72; } else if (roundedNumber3 > 1 && roundedNumber3 < 50) { result = 72 + 2 * roundedNumber3; } else if (roundedNumber3 > 50) { result = 100 * Math.log(roundedNumber3) - 219.2023; } result = Math.ceil(result); difference=result-Seedingtime if (Completed === 'no') { completeresults = 'Not completed'; } else if (Seedingtime > result) { completeresults = "Yes - Seeding requirement met"; } else if (Seedingtime < result) { completeresults = `You still need to seed ${difference} hours`; } else if (Upload > Download) { completeresults = 'Yes - Upload requirement met'; } const newColumnsData = [`<a href="${Href}">${Title}</a>`, Active, Completed, Seeders, Leechers, CompletedNr, rawFilesize, rawUpload, rawDownload, Ratio, result, Seedingtime, completeresults]; if (Download !== 0 && Completed !== 'no') { const newRow = newColumnsData.concat(Array.from(newColumnsData).slice(13).map(cell => cell)); newData.push(newRow); } } // Create a new div for spacing const spacerDiv = document.createElement("div"); spacerDiv.style.height = "50px"; // Adjust the height as needed spacerDiv.style.width = "100%"; // Ensure full width // Create a new table and populate it with the data const newTable = document.createElement("table"); newTable.style.marginTop = "20px"; // Add margin for spacing // Add CSS styles for the table newTable.style.borderCollapse = "collapse"; newTable.style.width = "100%"; // Create the header row const headerRow = newTable.insertRow(); columnNames.forEach(columnName => { const newHeaderCell = headerRow.insertCell(); newHeaderCell.textContent = columnName; newHeaderCell.style.border = "1px solid black"; // Add border newHeaderCell.style.padding = "8px"; // Add padding }); // Create data rows newData.forEach(rowData => { const newRow = newTable.insertRow(); rowData.forEach((cellData, columnIndex) => { const newCell = newRow.insertCell(); if (columnIndex === 0) { // For the first column (Title cell) newCell.innerHTML = cellData; // Use innerHTML for HTML content } else { newCell.textContent = cellData; } newCell.style.border = "1px solid black"; // Add border newCell.style.padding = "8px"; // Add padding }); }); // Replace the table with the spacer and new table table.parentNode.insertBefore(spacerDiv, table); table.parentNode.insertBefore(newTable, table); table.remove(); } function addColumnsToTable() { var table = document.querySelector('table'); // Select the table element if (table) { // Select the table header row // Select the table element for (let i = 0; i < table.rows.length; i++) { const row = table.rows[i]; // Check if the row has any cells if (row.cells.length > 0) { // Delete the first cell in the row row.deleteCell(0); } else { console.log("Row doesn't have any cells."); } } // Iterate over each row in the table var rowss = table.getElementsByTagName('tr'); console.log(rowss) var rows = Array.from(rowss).slice(1); console.log(rows) for (var i = 0; i < rows.length; i++) { var row = rows[i]; // Add functionality for the third column var element3 = row.children[5]; if (element3) { var value3 = element3.textContent; var regex=/(\d+(\.\d+)?)\s*(GB|MB|KB|TB)\b/i; var number3 = parseFloat(value3.match(regex)); console.log(number3) var roundedNumber3 = number3; var result = null; if (roundedNumber3 <= 1) { result = roundedNumber3; } else if (roundedNumber3 > 1 && roundedNumber3 < 50) { result = 72 + 2 * roundedNumber3; } else if (roundedNumber3 > 50) { result = 100 * Math.log(roundedNumber3) - 219.2023; } result = Math.ceil(result); // Create a new cell (column) element for the third column and append it to the row var cell3 = document.createElement('td'); cell3.textContent = result; cell3.style='border: 1px solid black; padding: 8px;' row.appendChild(cell3); } // Add functionality for the fourth column var element4 = row.querySelector('td:nth-of-type(11) span'); if (element4) { var value4 = element4.getAttribute('data-original-title'); var number4 = parseFloat(value4.match(/\d+(\.\d+)?/)) / 60; var roundedNumber4 = Math.floor(number4); // Create a new cell (column) element for the fourth column and append it to the row var cell4 = document.createElement('td'); cell4.textContent = roundedNumber4; cell4.style='border: 1px solid black; padding: 8px;' row.appendChild(cell4); } // Add functionality for the fifth column if (element3 && element4) { var cell5 = document.createElement('td'); if (roundedNumber4 < result) { cell5.textContent = "not done"; } else { cell5.textContent = "done"; } row.appendChild(cell5); } } } } replaceTable(); function makeTableSortable() { const table = document.querySelector("table"); if (!table) { console.error("Table not found."); return; } const headers = table.rows[0].cells; function sortTable(columnIndex) { const rows = Array.from(table.rows); rows.sort((a, b) => { const aValue = a.cells[columnIndex].textContent; const bValue = b.cells[columnIndex].textContent; return aValue.localeCompare(bValue); }); // Reorder rows in the table rows.forEach(row => table.appendChild(row)); } function addSortingIcons() { headers.forEach((header, columnIndex) => { const sortingIcon = document.createElement('i'); sortingIcon.className = 'fa fa-sort'; header.appendChild(sortingIcon); header.addEventListener('click', () => { sortTable(columnIndex); }); }); } addSortingIcons(); } // Call the function to make the table sortable // makeTableSortable(); })();