ScrapboxからCLASSのページにアクセスするUserScript
GM_xmlhttpRequestでオリジンを越えてデータを取得できるようにした
2021-04-05 21:56:57 response typeを指定できるようにした
code:script.js
// ==UserScript==
// @name CLASS Proxy for Scrapbox
// @namespace https://scrapbox.io
// @version 0.2
// @description CLASSからweb pageを取得します
// @author takker
// @match https://scrapbox.io/*
// @connect class.admin.tus.ac.jp
// @grant GM_xmlhttpRequest
// @license MIT
// @copyright Copyright (c) 2021 takker
// ==/UserScript==
"use strict"
unsafeWindow.fetchCLASS = (pathname, {method, headers, body, type} = {}) => new Promise(resolve => GM_xmlhttpRequest({
url: https://class.admin.tus.ac.jp${pathname},
method: method ?? 'GET',
...(headers ? {headers} : {}),
...(body ? {data: body} : {}),
...(type ? {responseType: type} : {}),
onload: (res) => resolve(res),
withCredentials: true,
}));
#CLASS
#2021-04-05 21:56:11
#2021-02-24 05:12:10