您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
简书Markdown格式转换
当前为
// ==UserScript== // @name JianShu Formatter 简书Markdown格式转换 // @namespace http://tampermonkey.net/ // @namespace https://www.jianshu.com/u/15893823363f // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js // @version 2.2 // @description 简书Markdown格式转换 // @author Zszen // @match https://www.jianshu.com/writer // @grant none // ==/UserScript== (function() { 'use strict'; //var targetEditor = $("#arthur-editor"); initMe() function initMe(){ setTimeout(function(){ var btUpdate = $("a.fa.fa-columns"); if(!btUpdate){ initMe(); return; } btUpdate.on('click',initMe); // console.log( $("ul.clearfix")); var addedBt = $('<li class="_2zLpt"><a class="fa format-code" data-action="">格</a></li>'); $("ul.clearfix").append(addedBt); addedBt.on('click', formatInput) addedBt = $('<li class="_2zLpt"><a class="fa insert-title" data-action="">插</a></li>'); $("ul.clearfix").append(addedBt); addedBt.on('click', addTitle) },800) } function formatInput(){ var txt = $("textarea"); //console.log(txt.val()); var str = txt.val(); str = str.replace(/···/g,'```') str = str.replace(/·/g,'`') str = str.replace(/〈|《/g,'<') str = str.replace(/〉|》/g,'>') //str = str.replace(//g,'<') //str = str.replace(//g,'>') str = str.replace(/「|『/g,'{') str = str.replace(/』|」/g,'}') //console.log(str); txt.val(str) } function addTitle(){ var txt = $("textarea"); //var startPos = txt.selectionStart; //console.log(startPos) insertAtCursor(txt,"\n___\n####") setSelectionRange(txt,txt.value.length,txt.value.length); } function insertAtCursor(myField, myValue) { if (document.selection) { //IE support myField.focus(); sel = document.selection.createRange(); sel.text = myValue; // sel.select(); } else if (myField.selectionStart || myField.selectionStart == '0') { //MOZILLA/NETSCAPE support var startPos = myField.selectionStart; var endPos = myField.selectionEnd; var beforeValue = myField.value.substring(0, startPos); var afterValue = myField.value.substring(endPos, myField.value.length); myField.value = beforeValue + myValue + afterValue; myField.selectionStart = startPos + myValue.length; myField.selectionEnd = startPos + myValue.length; // myField.focus(); } else { //myField.value += myValue; myField.val(myField.val()+myValue) // myField.focus(); } } function setSelectionRange(input, selectionStart, selectionEnd) { if (input.setSelectionRange) { input.focus(); input.setSelectionRange(selectionStart, selectionEnd); }else if (input.createTextRange) { var range = input.createTextRange(); range.collapse(true); range.moveEnd('character', selectionEnd); range.moveStart('character', selectionStart); range.select(); } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址