TJUPT - Direct Links

将 TJUPT 中的外链转换为直接链接

目前為 2019-05-31 提交的版本,檢視 最新版本

// ==UserScript==
// @name TJUPT - Direct Links
// @namespace https://github.com/whtsky/userscripts/
// @version 20190530
// @description 将 TJUPT 中的外链转换为直接链接
// @match https://tjupt.org/*
// @grant none
// @supportURL https://github.com/whtsky/userscripts/issues
// ==/UserScript==


function removeTo(s, to) {
  const index = s.search(to);
  if (index !== -1) {
    return s.substr(index + to.length);
  }
  return s;
}


document.querySelectorAll('a').forEach(anchor => {
  let link = anchor.href;
  if (link.startsWith("https://tjupt.org/adredir.php")) {
    link = removeTo(link, "url=");
  } else if (link.startsWith("https://tjupt.org/jump_external.php")) {
    link = removeTo(link, "ext_url=");
  } else {
    return;
  }
  anchor.href = decodeURIComponent(link);
})

QingJ © 2025

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