AutoCorrect.plugin.js.zip

  • Tru1
    了解作者
  • JavaScript
    开发工具
  • 20KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-02-22 02:34
    上传日期
auto correct plugin for BD
AutoCorrect.plugin.js.zip
  • AutoCorrect.plugin.js
    20.6KB
内容介绍
//META{"name":"AutoCorrect","website":"https://github.com/Metalloriff/BetterDiscordPlugins/blob/master/README.md","source":"https://github.com/Metalloriff/BetterDiscordPlugins/blob/master/AutoCorrect.plugin.js"}*// class AutoCorrect { getName() { return "AutoCorrect"; } getDescription() { return "Automatically replaces misspelled words with the first correction, with optional automatic capitalization and punctuation. Requires either Windows 8 or above, Mac, or DevilBro's SpellCheck plugin."; } getVersion() { return "1.3.5"; } getAuthor() { return "Metalloriff"; } getChanges() { return { "1.2.4" : ` Fixed learned words. Words ending with any non-alphanumeric character will no longer be automatically punctuated, instead of only words ending with punctuation. Added a "prevent multiple spaces between words" setting. Fixed auto-completes not completing when sending. Fixed auto-emojis. Fixed a bunch of little bugs, and probably created some. Code blocks are no longer corrected. `, "1.3.4" : ` Fixed the plugin failing to load for the first time if attach to all fields was disabled. Fixed newlines putting random spaces. Fixed the inability to put spaces in code blocks. Added a "minimum auto-punctuate word count" setting. ` }; } load() {} start() { let libLoadedEvent = () => { try{ this.onLibLoaded(); } catch(err) { console.error(this.getName(), "fatal error, plugin could not be started!", err); try { this.stop(); } catch(err) { console.error(this.getName() + ".stop()", err); } } }; let lib = document.getElementById("NeatoBurritoLibrary"); if(!lib) { lib = document.createElement("script"); lib.id = "NeatoBurritoLibrary"; lib.type = "text/javascript"; lib.src = "https://rawgit.com/Metalloriff/BetterDiscordPlugins/master/Lib/NeatoBurritoLibrary.js"; document.head.appendChild(lib); } this.forceLoadTimeout = setTimeout(libLoadedEvent, 30000); if(typeof window.NeatoLib !== "undefined") libLoadedEvent(); else lib.addEventListener("load", libLoadedEvent); } getSettingsPanel() { setTimeout(() => { NeatoLib.Settings.pushElement(NeatoLib.Settings.Elements.createToggleGroup("ac-toggle-group", "General options", [ { title : "Use DevilBro's SpellCheck", value : "useDevilsChecker", setValue : this.settings.useDevilsChecker }, { title : "Don't correct the same word twice", value : "dontCorrectTwice", setValue : this.settings.dontCorrectTwice }, { title : "Automatically capitalize the first letter of every sentence", value : "autoCapitalization", setValue : this.settings.autoCapitalization }, { title : "Automatically punctuate on send and on double space", value : "autoPunctuation", setValue : this.settings.autoPunctuation }, { title : "Automatically correct spelling errors", value : "autoCorrect", setValue : this.settings.autoCorrect }, { title : "Ignore messages beginning with a space", value : "ignoreEmptyStart", setValue : this.settings.ignoreEmptyStart }, { title : "Attach corrector to every text field (set this to false for just the chatbox)", value : "attachEverywhere", setValue : this.settings.attachEverywhere }, { title : "Prevent multiple spaces between words", value : "preventDoubleSpaces", setValue : this.settings.preventDoubleSpaces } ], choice => { this.settings[choice.value] = !this.settings[choice.value]; this.saveSettings(); }), this.getName()); NeatoLib.Settings.pushElement(NeatoLib.Settings.Elements.createNewTextField("Ignored prefixes", this.settings.ignoredPrefixes, e => { this.settings.ignoredPrefixes = e.target.value; this.saveSettings(); }, { description : "Any messages beginning with any of these prefixes will be ignored. Good for preventing bot commands from failing due to corrections. Separate with spaces." }), this.getName()); NeatoLib.Settings.pushElement(NeatoLib.Settings.Elements.createHint("Hint: You can stop a word from being corrected by selecting the word, right clicking, and clicking \"Learn Word\", or by adding it to your learned words list in the settings."), this.getName()); let group = NeatoLib.Settings.Elements.createGroup("Override replacers", { style : "background-color:rgba(0,0,0,0.2);border-radius:5px;padding:10px;text-align:center;" }), list = group.lastChild; group.insertAdjacentHTML("afterbegin", `<style>.ac-selected{background-color:#7289da;border-radius:5px;}</style>`); let buildGroup = () => { list.innerHTML = ""; this.selectedReplacer = -1; for(let i = 0; i < this.settings.overrideReplacers.length; i++) { list.insertAdjacentHTML("beforeend", `<div type="text" class="ac-replacer-field"><input value="${this.settings.overrideReplacers[i].word}" style="${NeatoLib.Settings.Styles.textField}width:45%;margin:2.5%;border:2px solid white;"><input value="${this.settings.overrideReplacers[i].replacement}" style="${NeatoLib.Settings.Styles.textField}width:45%;margin:2.5%;border:2px solid white;"></div>`); let added = document.getElementsByClassName("ac-replacer-field")[i]; added.addEventListener("click", e => { for(let selected of group.getElementsByClassName("ac-replacer-field")) selected.classList.remove("ac-selected"); this.selectedReplacer = i; e.currentTarget.classList.add("ac-selected"); }); let fields = added.getElementsByTagName("input"); for(let ii = 0; ii < fields.length; ii++) fields[ii].addEventListener("focusout", e => { this.settings.overrideReplacers[i] = { word : fields[0].value, replacement : fields[1].value }; this.saveSettings(); }); } list.insertAdjacentElement("beforeend", NeatoLib.Settings.Elements.createButton("Add New Replacer", () => { this.settings.overrideReplacers.push({ word : "", replacement : "" }); this.saveSettings(); buildGroup(); }, "margin-right:20px")); list.insertAdjacentElement("beforeend", NeatoLib.Settings.Elements.createButton("Remove Selected", () => { if(this.selectedReplacer == -1) { NeatoLib.showToast("No replacer selected!"); return; } this.settings.overrideReplacers.splice(this.selectedReplacer, 1); this.saveSettings(); buildGroup(); NeatoLib.showToast("Replacer removed!", "success"); }, "margin-left:20px")); }; NeatoLib.Settings.pushElement(group, this.getName()); buildGroup(); NeatoLib.Settings.pushElement(NeatoLib.Settings.Elements.createNewTextField("Learned words (separate with spaces)", this.settings.learnedWords.join(" "), e => { this.settings.learnedWords = e.target.value.trim().toLowerCase().split(" ").filter(x => x != ""); this.saveSettings(); }), this.getName()); NeatoLib.Settings.pushElement(NeatoLib.Settings.Elements.createNewTextField("Auto-punctuation: minimum word count", this.settings.autoPunctuationMin, e => { this.settings.autoPunctuationMin = e.target.value; this.saveSettings(); }), this.getName(), { tooltip : "If this is above 0, this many or more words will be required before auto-punctuating" }); NeatoLib.Settings.pushChangelogElements(this); }, 0); return NeatoLib.Settings.Elements.pluginNameLabel(this.getName()); } saveSettings() { if(this.settings.useDevilsChecker) { this.devilsChecker = BdApi.getPlugin("SpellCheck"); let toggle = document.getElementById("ac-toggle-group-0"); if(toggle) toggle = toggle.getElementsByTagName("input")[0]; if(this.devilsChecker) { if(window.pluginCookie["SpellCheck"] == false) { NeatoLib.showToast("DevilBro's SpellCheck is not enabled! Please enable it and re-enable this setting.", "error"); if(toggle) toggle.click(); }else for(let i = 0; i < this.settings.learne
评论
    相关推荐
    • autorunner
      AutoRunner指的是黑盒测试工具,可以用来执行重复的手工测试。主要用于功能测试、回归测试等工作的自动化。它采用数据驱动和参数化的理念,通过录制用户对被测系统的操作,生成自动化脚本,然后让计算机执行自动化...
    • Auto Start
      Microsoft virsual Studio 2005 C++ ATL Auto Start Addin。
    • autolisp游戏俄罗斯方块
      AutoCAD平台的autolisp游戏程序,载入后输入elsbox即可游戏
    • autolisp游戏打飞机
      autocad平台的打飞机游戏程序,加载后输入troy快捷键即可游戏
    • autorunner
      AutoRunner是黑盒测试工具,可以用来完成功能测试、回归测试,可以提高测试效率,降低测试人工成本。
    • auto-fontsize
      npm i auto-fontsize --save 用法 import {AutoFontSize} from 'auto-fontsize 参数 财产 类型 选修的 默认 笔记 文本 细绳 错误的 不适用 要显示的文字 fontSizeMapping IFontSizeLineHeightMapping [] 真的 不...
    • AndroidAuto
      android auto开发官方的文档,确认以下这些对你有用再下载: SDK Contents The SDK is distributed as Android Pre-Release Software pursuant to the Android Automotive Pre-Release Software License Agreement. ...
    • auto
      应用程序可查询公司自动数据库并在数据过期时负责发送电子邮件
    • auto.zip
      auto file from a super puper project
    • AutoCAD 2010 AutoLISP参考手册.rar
      基于AutoCAD2010系统下的AutoLISP编程参考手册,本手册从系统中提取。