UserScript:install-CDN
cdnjsなどからscrapboxにscriptを読み込むための関数 code:script.js
export const installCDN = ({id, src, module = false} = {}) => new Promise((resolve, reject) => {
const oldScript = document.getElementById(id);
oldScript?.parentNode.removeChild(oldScript);
const script = document.createElement("script");
script.addEventListener('load', () => resolve());
script.addEventListener('error', ev => reject(ev));
script.src = src;
script.id = id;
if (module) { script.type = 'module'; }
document.head.appendChild(script);
});
UserScript.icon