CORS-via-GM

CORS via Greasemonkey/Tampermonkey

Автор
WeAreHighering
Щоденних встановлень
0
Всього встановлень
41
Рейтинги
0 0 0
Версія
2.0
Створено
01.05.2023
Оновлено
02.05.2023
Ліцензія
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>