Greasy Fork

Jigen's other stuff

Add CSS + Check WKOF

目前为 2018-06-08 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.icu/scripts/369353/604090/Jigen%27s%20other%20stuff.js

(function(global) {
	var jigen = {
		addStyle: addStyle,
		checkWKOF: checkWKOF
	};

    function addStyle(aCss) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (head) {
            style = document.createElement('style');
            style.setAttribute('type', 'text/css');
            style.textContent = aCss;
            head.appendChild(style);
            return style;
        }
        return null;
    }
	function checkWKOF(name,version){
		if (!window.wkof) {
			if (confirm(name + ' requires Wanikani Open Framework.\nDo you want to be forwarded to the installation instructions?'))
				window.location.href = 'https://community.wanikani.com/t/instructions-installing-wanikani-open-framework/28549';
			return;
		}
		if(version != undefined){
			if (wkof.version.compare_to(version) === 'older') {
				if (confirm(name + ' requires Wanikani Open Framework version ' + version + '.\nDo you want to be forwarded to the update page?'))
					window.location.href = 'https://greasyfork.org/en/scripts/38582-wanikani-open-framework';
				return;
			}
		}
	}

	global.jigen = jigen;
})(jQuery);