MagnetDL Subtitles

Quickly know if a file has subtitles or not.

目前為 2024-04-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         MagnetDL Subtitles
// @namespace    https://gf.qytechs.cn/en/users/670188-hacker09?sort=daily_installs
// @version      1
// @description  Quickly know if a file has subtitles or not.
// @author       hacker09
// @match        https://www.magnetdl.com/file/*
// @icon         https://www.magnetdl.com/img/m.gif
// @run-at       document-end
// @grant        none
// ==/UserScript==

(async function() {
  'use strict';
  document.head.insertAdjacentHTML('afterbegin', '<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">'); //Bypass the Mixed Content error

  const response = await fetch('https://www.magnetdl.com/info/x' + document.querySelector("[href^='javascript\\:Information\\(\\'file_x']").href.match(/file_x(\d+)/)[1]); //Fetch
  const html = await response.text(); //Gets the fetch response
  const newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response

  if(document.body.innerText.includes('.srt') || /(subtitle|(TEXT\/)?UTF-?8|VobSub)/gi.test(newDocument.body.innerText)) { //If the INFO contains a text that means that it has subtitles
    document.querySelector("[href^='javascript\\:Information\\(\\'file_x']").textContent += ' (HAS SUBS!)'; //Add a message in the INFO text
  }
  else //If the info doesn't contain a text that means that it has subtitles
  {
    document.querySelector("[href^='javascript\\:Information\\(\\'file_x']").textContent += ' (NO SUBS!)'; //Add a message in the INFO text
  }
  document.querySelector("[href^='javascript\\:Information\\(\\'file_x']").href = 'https://www.magnetdl.com/info/x' + document.querySelector("[href^='javascript\\:Information\\(\\'file_x']").href.match(/file_x(\d+)/)[1]; //Fix the Ublock Origin issue that makes the INFO button not work
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址