Skip to content

Instantly share code, notes, and snippets.

@bxb100
Created June 4, 2023 13:33
Show Gist options
  • Save bxb100/6c323c86c14957838d6c686ef7f354fb to your computer and use it in GitHub Desktop.
Save bxb100/6c323c86c14957838d6c686ef7f354fb to your computer and use it in GitHub Desktop.

复制以下代码放到控制台即可

  • 去除 tracker 中 id 的部分
const cUrl = window.location.href;
const tracker = 'www.pttime.org';

const doEdit = async function (t) {
  if (!t.tracker.includes(tracker)) {
    console.log(t.hash, 'tracker不包含', tracker, '跳过');
    return;
  }
  const newTracker = t.tracker.replaceAll(/&id=.*/g, "")
  const oldTracker = t.tracker
  await fetch(cUrl + `api/v2/torrents/editTracker?hash=${t.hash}&origUrl=${encodeURIComponent(oldTracker)}&newUrl=${encodeURIComponent(newTracker)}`);
  console.log(t.hash, '已编辑');
};

const request = async ({url}) => {
  const res = await fetch(url);
  return await res.json();
}

(async function () {
  'use strict';
  const torrents = await request({url: `${cUrl}api/v2/torrents/info`});
  for (const t of torrents) {
    try {
      await doEdit(t);
    } catch (e) {
      console.error(e);
    }
  }
  console.log('已全部完成');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment