1337x - Mark Untrusted

Marks torrents uploaded by untrusted users by fetching names from the pirated games list.

当前为 2024-09-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 1337x - Mark Untrusted
  3. // @namespace https://greasyfork.org/es/users/825144-aitronz
  4. // @version 1.5
  5. // @description Marks torrents uploaded by untrusted users by fetching names from the pirated games list.
  6. // @author aitronz
  7. // @match *://1337x.to/*
  8. // @match *://1337x.st/*
  9. // @match *://x1337x.ws/*
  10. // @match *://x1337x.eu/*
  11. // @match *://x1337x.se/*
  12. // @match *://x1337x.cc/*
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. const userListURL = 'https://rentry.org/pgames/raw';
  21.  
  22. const normalizeName = name => {
  23. let normalized = name.replace(/\s+/g, '').toLowerCase().replace(/[^a-z0-9]/g, '');
  24. return normalized.includes('igggames') && !normalized.includes('igggamescom') ? normalized + 'com' : normalized;
  25. };
  26.  
  27. const markRows = userList => {
  28. document.querySelectorAll('table.table-list tbody tr').forEach(row => {
  29. const uploaderCell = row.querySelector('.coll-5 a');
  30. if (uploaderCell) {
  31. const normalizedUploader = normalizeName(uploaderCell.textContent.trim());
  32. if (userList.includes(normalizedUploader)) {
  33. row.style.cssText = 'background-color: #cccccc; opacity: 0.5; position: relative;';
  34. const untrustedLabel = Object.assign(document.createElement('div'), {
  35. textContent: 'Untrusted',
  36. style: 'position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); color: red; font-size: 20px; font-weight: bold; text-align: center; line-height: ' + row.offsetHeight + 'px; pointer-events: none; z-index: 1;'
  37. });
  38. row.appendChild(untrustedLabel);
  39. }
  40. }
  41. });
  42. };
  43.  
  44. const fetchUserList = () => {
  45. fetch(userListURL)
  46. .then(response => response.text())
  47. .then(data => {
  48. const userList = [];
  49. const startSection = "###Untrusted uploaders";
  50. const endSection = "*****";
  51. const startIdx = data.indexOf(startSection);
  52. const endIdx = data.indexOf(endSection, startIdx);
  53. const untrustedSection = data.substring(startIdx, endIdx);
  54. const lines = untrustedSection.split("\n");
  55. const exclusionPhrase = "Any user from The Pirate Bay / TPB";
  56.  
  57. lines.forEach(line => {
  58. const trimmedLine = line.trim();
  59. if (trimmedLine.startsWith("-")) {
  60. if (!trimmedLine.includes(exclusionPhrase)) {
  61. let uploader = trimmedLine.slice(1).replace(/\*/g, '').trim();
  62. if (uploader.includes(" - ")) {
  63. uploader = uploader.split(" - ")[0].trim();
  64. }
  65. userList.push(...uploader.split("/").map(normalizeName));
  66. }
  67. }
  68. });
  69.  
  70. console.log('List of untrusted uploaders:', userList);
  71. markRows(userList);
  72. })
  73. .catch(console.error);
  74. };
  75.  
  76. const waitForTable = () => {
  77. const checkInterval = setInterval(() => {
  78. if (document.querySelector('table.table-list tbody')) {
  79. clearInterval(checkInterval);
  80. fetchUserList();
  81. }
  82. }, 50);
  83. };
  84.  
  85. waitForTable();
  86. })();