kknowcc-imgur-proxy

kk.now.cc使用的是imgur图床,这个图床将大多数IP列入了黑名单导致图片无法正常加载,本脚本将论坛中所有imgur的图片链接替换成其镜像网站noobzone的链接以解决图片显示问题。

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        kknowcc-imgur-proxy
// @namespace   Violentmonkey Scripts
// @match       https://kk.now.cc/**/*
// @grant       GM_xmlhttpRequest
// @version     1.0
// @author      Mesimpler
// @license     MIT
// @require     https://cdn.jsdelivr.net/npm/@violentmonkey/dom@2
// @description kk.now.cc使用的是imgur图床,这个图床将大多数IP列入了黑名单导致图片无法正常加载,本脚本将论坛中所有imgur的图片链接替换成其镜像网站noobzone的链接以解决图片显示问题。
// ==/UserScript==

// 代理URL
const PROXY_URL = "https://img.noobzone.ru/getimg.php?url=";

// 处理单个图片元素
function processImage(img) {
  const originalSrc = img.src;

  // 检查是否是Imgur图片
  if (originalSrc.startsWith("https://i.imgur.com/")) {
    // 创建代理URL
    const proxySrc = PROXY_URL + encodeURIComponent(originalSrc);

    // 使用GM_xmlhttpRequest绕过CORS和防盗链
    GM_xmlhttpRequest({
      method: "GET",
      url: proxySrc,
      responseType: "blob",
      onload: function (response) {
        if (response.status === 200) {
          // 创建对象URL并设置给img元素
          const blob = response.response;
          const objectUrl = URL.createObjectURL(blob);
          img.src = objectUrl;

          // 清理内存(可选)
          img.onload = function () {
            URL.revokeObjectURL(objectUrl);
          };
        } else {
          console.error("图片加载失败:", response.status, response.statusText);
        }
      },
      onerror: function (error) {
        console.error("请求错误:", error);
      },
    });
  }
}

// 处理所有现有图片
function processAllImages() {
  const images = document.querySelectorAll('img[src^="https://i.imgur.com/"]');
  images.forEach(processImage);
}

// 使用MutationObserver监听动态加载的图片
VM.observe(document.body, () => processAllImages());

// 初始处理
processAllImages();