CORS-via-GM

CORS via Greasemonkey/Tampermonkey

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
WeAreHighering
今日安裝
0
安裝總數
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>