您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button to add <br> in mediawiki form
当前为
- // ==UserScript==
- // @name Mediawiki <br> adder
- // @version 0.1.0
- // @description Adds a button to add <br> in mediawiki form
- // @author kory33
- // @match *://*/*
- // @namespace https://github.com/kory33
- // ==/UserScript==
- (function() {
- 'use strict';
- function addButton(text, domManipulator) {
- const button = document.createElement('button');
- const textarea = document.getElementById("wpTextbox1");
- document.getElementById("mw-content-text").appendChild(button);
- button.innerHTML = text;
- button.onclick = () => domManipulator(textarea);
- return button;
- }
- function processText(text) {
- const lines = text.split("\n");
- const shouldAppendBr = line => !(line === "" || line.endsWith(">") || line.endsWith("=="));
- const mapper = line => shouldAppendBr(line) ? line + "<br>" : line;
- return lines.map(mapper).join("\n");
- }
- window.addEventListener('load', () => {
- addButton('Add <br>', (textarea) => {
- textarea.value = processText(textarea.value);
- });
- });
- })();