CORS-via-GM

CORS via Greasemonkey/Tampermonkey

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
WeAreHighering
日安装量
1
总安装量
71
评分
0 0 0
版本
2.0
创建于
2023-05-01
更新于
2023-05-02
大小
2.4 KB
许可证
WTFPL
适用于

Description

This script enables web front-end developers to bypass CORS to directly access other domains in the easiest and no-fuss way.

Notice

The most important update of v2.0 compared to v1.0 is support for non-text type response data!

Usages

(Just install this script and open the console on this page to try it out!)

  • Simplest trial

    CORSViaGM.init()
    fetch('https://example.com')
    
  • (Bad fun)
    Replace any first picture on the current page with the DuckDuckGo icon.

    CORSViaGM.init()
    url = 'https://duckduckgo.com/favicon.ico'
    img = Object.assign(new Image, { src: URL.createObjectURL(await (await fetch(url)).blob()) })
    document.querySelector('img')?.replaceWith(img)
    
  • (More advanced)
    If you want to await window._CORSViaGM.inited, add the following element to the <head> of your index.html:

    <script>
     window._CORSViaGM = (inited => ({ inited: Object.assign(new Promise(r => inited = r), { done: inited }) }))()
    </script>