Set CTAN Mirror

Set to use a fixed mirror when browsing CTAN files.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         Set CTAN Mirror
// @name:zh      设置 CTAN 默认镜像
// @name:zh-CN   设置 CTAN 默认镜像
// @namespace    https://github.com/rnicrosoft-studio/
// @version      0.3
// @description  Set to use a fixed mirror when browsing CTAN files.
// @description:zh  设置浏览 CTAN 文件时使用一个固定的镜像。
// @description:zh-CN   设置浏览 CTAN 文件时使用一个固定的镜像。
// @author       rnicrosoft
// @supportURL   https://github.com/rnicrosoft-studio/tampermonkey-scripts
// @match        *://www.ctan.org/*
// @match        *://ctan.org/*
// @icon         https://www.ctan.org/assets/favicon/favicon-32x32.png
// @run-at       document-end
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';

    // First, set the endpoint of your preferred mirror host here.
    // Check <https://ctan.org/mirrors/mirmon> for the latest active CTAN mirrors list.
    var mirrorEndpoint = 'mirrors.sjtug.sjtu.edu.cn/ctan';

    document.querySelectorAll('a[href^="http://mirrors.ctan.org"], a[href^="https://mirrors.ctan.org"]').forEach(function(item) {
        //console.log(item.getAttribute('href'))
        item.setAttribute('href',
                          item.getAttribute('href').replace('mirrors.ctan.org', mirrorEndpoint))
    })
})();