您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Shared code for my scripts
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/446540/1061588/ENSShared.js
- const c = document.createElement("canvas");
- const ctx = c.getContext("2d");
- const imageToBlob = (imageURL) => {
- const img = new Image;
- img.crossOrigin = "";
- img.src = imageURL;
- return new Promise(resolve => {
- img.onload = function () {
- c.width = this.naturalWidth;
- c.height = this.naturalHeight;
- ctx.drawImage(this, 0, 0);
- c.toBlob((blob) => {
- resolve(blob)
- }, "image/png", 0.75);
- };
- })
- }
- const toggleAttribute = (elem, attr, val) => {
- const tgattr = (elem, attr, val) => {
- if (elem.hasAttribute(attr)) {
- let atrval = elem.getAttribute(attr);
- if (atrval.includes(val)) {
- let rep = atrval.replace(val, '');
- !rep.length ? elem.removeAttribute(attr) : elem.setAttribute(attr, rep);
- } else elem.setAttribute(attr, elem.getAttribute(attr) + val);
- } else elem.setAttribute(attr, val);
- }
- if (elem instanceof Array) {
- for (let key in elem) {
- tgattr(elem[key], attr, val);
- }
- } else tgattr(elem, attr, val);
- }
- const awaitSelector = (selector) => {
- return new Promise((resolve) => {
- const nodes = [];
- setInterval(() => {
- if (nodes.length !== 0) {
- clearInterval(tm);
- resolve(nodes);
- }
- nodes.splice(nodes.length, 0, ...document.querySelectorAll(selector));
- }, 100);
- });
- }