您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Support maths for DartCounter score entry.
当前为
// ==UserScript== // @name DartCounter Calculator // @author mrdarts180 // @namespace http://dartcounter.net/ // @version 1.1 // @license MIT // @description Support maths for DartCounter score entry. // @match http*://dartcounter.net/* // @icon https://dartcounter.net/favicon-32x32.png // @require https://unpkg.com/mathjs/lib/browser/math.js // @grant GM_addStyle // ==/UserScript== GM_addStyle("#score.w-32 { width: 32rem!important; }"); (function() { 'use strict'; var observer = new MutationObserver(function(mutations) { var scoreInput = document.getElementById("score"); if (scoreInput) { scoreInput.type = 'text'; scoreInput.disabled = false; scoreInput.setAttribute('autocomplete', 'off'); } }); observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true}); document.addEventListener('keydown', (event) => { var scoreInput = document.getElementById("score"); if (scoreInput && event.target == scoreInput) { if (event.keyCode == 13) { let calcScore = (str) => { return math.evaluate(str); }; let scoreValue = scoreInput.value; if (scoreValue && scoreValue.length > 0) { scoreInput.value = calcScore(scoreValue); scoreInput.dispatchEvent( new Event("input", { bubbles: true, cancelable: true }) ); event.stopPropagation(); scoreInput.dispatchEvent(new KeyboardEvent('keydown', {'key': 'Enter'})); } } } }, true); })();