經濟學人油猴指令碼

zed99發表於2024-04-09
// ==UserScript==
// @name     Combined Google Web Cache Redirect and Link Modifier
// @version  1.1
// @grant    none
// @match    *://*/*
// @run-at   document-start
// ==/UserScript==
(function() {
    'use strict';

    var currentUrl = window.location.href;
    var urlObj = new URL(currentUrl);

    // 僅使用協議、主機名和路徑構建Google快取的URL
    var baseUrl = urlObj.origin + urlObj.pathname;

    if ((urlObj.hostname.includes("www.economist.com") || urlObj.hostname.includes("www.theatlantic.com")) && !currentUrl.includes("webcache.googleusercontent.com/search?q=cache:")) {
        // 構建Google快取的URL
        var cacheUrl = "https://webcache.googleusercontent.com/search?q=cache:" + baseUrl;

        // 重定向到Google快取的URL
        window.location.href = cacheUrl;
    }
})();

相關文章