Greasy Fork

live2d看板娘全站显示

在所有网站显示一个看板娘

目前为 2022-07-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         live2d看板娘全站显示
// @license MIT
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  在所有网站显示一个看板娘
// @author       FiresonZ
// @content_security_policy script-src 'self' 'unsafe-eval'; object-src 'self'
// @include      *
// @grant        none
// ==/UserScript==

const live2d_path = "https://firesonz.top/live2d/";
function loadExternalResource(url, type) {
	return new Promise((resolve, reject) => {
		let tag;

		if (type === "css") {
			tag = document.createElement("link");
			tag.rel = "stylesheet";
			tag.href = url;
		}
		else if (type === "js") {
			tag = document.createElement("script");
			tag.src = url;
		}
		if (tag) {
			tag.onload = () => resolve(url);
			tag.onerror = () => reject(url);
			document.head.appendChild(tag);
		}
	});
}
if (screen.width >= 768) {
	Promise.all([
		loadExternalResource(live2d_path + "waifu.css", "css"),
		loadExternalResource(live2d_path + "live2d.min.js", "js"),
		loadExternalResource(live2d_path + "waifu-tips.js", "js")
	]).then(() => {
		initWidget({
			waifuPath: live2d_path + "waifu-tips.json",
			cdnPath: "https://firesonz.top/api/"
		});
	});
}
console.log('CDN由FiresonZ的博客提供~');