assets

Wenku8++ basic assets support

目前为 2022-08-26 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/449712/1085778/assets.js

/* eslint-disable no-multi-spaces */
/* eslint-disable userscripts/no-invalid-headers */
/* eslint-disable userscripts/no-invalid-grant */
/* eslint-disable no-implicit-globals */

// ==UserScript==
// @name               assets
// @namespace          Wenku8++
// @version            0.1
// @description        Wenku8++ basic assets support
// @author             PY-DNG
// @license            GPL-v3
// @regurl             https?://www\.wenku8\.net/.*
// ==/UserScript==

(function() {
	const ClassName = {
		Button: 'plus_btn',
		Text: 'plus_text'
	};
	const URL = {};
	const CSS = {
		Button_Text_Disabled: '.{CT} {color: rgb(30, 100, 220) !important;} .{CB} {color: rgb(0, 160, 0) !important; cursor: pointer !important; user-select: none;} .{CB}:hover {color: rgb(0, 100, 0) !important;} .{CB}:focus {color: rgb(0, 100, 0) !important;} .{CB}.{CD} {color: rgba(150, 150, 150) !important; cursor: not-allowed !important;}'.replaceAll('{CB}', CLASSNAME_BUTTON).replaceAll('{CT}', CLASSNAME_TEXT).replaceAll('{CD}', CLASSNAME_DISABLED)
	};
	const Number = {
		Interval: 500
	};
	const Text = {
		'zh-CN': {}
	};

	// Init language
	let i18n = navigator.language;
	let i18n_default = 'zh-CN';
	if (!Object.keys(Text).includes(i18n)) {i18n = i18n_default;}

	// Common css
	addStyle(CSS.Button_Text_Disabled);

	// Export
	exports = {
		ClassName: ClassName,
		URL: URL,
		CSS: CSS,
		Number: Number,
		Text: Text[i18n],
		Text_Full: Text
	}

	// Append a style text to document(<head>) with a <style> element
	function addStyle(css, id) {
		const style = document.createElement("style");
		id && (style.id = id);
		style.textContent = css;
		for (const elm of document.querySelectorAll('#' + id)) {
			elm.parentElement && elm.parentElement.removeChild(elm);
		}
		document.head.appendChild(style);
	}
}) ();