Greasy Fork

Greasy Fork is available in English.

解除img被跨源屏蔽

部分网站使用的图床是类似于gitee等仓库,因为他们禁止把他们的产品作为图床使用,所以使用这个脚本解除跨源策略,可以在一定程度上解决浏览网站部分图片无法加载的问题。

当前为 2024-06-08 提交的版本,查看 最新版本

// ==UserScript==
// @name         解除img被跨源屏蔽
// @namespace    http://tampermonkey.net/
// @version      0.0.2
// @description  部分网站使用的图床是类似于gitee等仓库,因为他们禁止把他们的产品作为图床使用,所以使用这个脚本解除跨源策略,可以在一定程度上解决浏览网站部分图片无法加载的问题。
// @author       pytdong
// @match  *://*/*
// @match  https://*/*
// @match http://*/*
// @icon         https://gitee.com/pyccer/picture-bed/raw/master/pytdong-icon.jpg
// @run-at document-idle
// @grant        none
// @license  MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    const imgList = document.querySelectorAll('img')
    imgList.forEach((value) => {
      let src = value.getAttribute('src')
      if (!src.startsWith('data:')) {
        value.setAttribute('referrerpolicy', 'no-referrer')
        src += "/?aseed=1" // 将来可以考虑更改为aseed=Math.random();但是不如这样效率高。
        value.setAttribute('src',src) 
      }
      
    })
})();