您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Checks PRE and CODE tags in Summernote and ensures that their contents use HTML entities for proper display.
当前为
// ==UserScript== // @name Kanka Preserve HTML Entities in Summernote // @namespace http://tampermonkey.net/ // @version 2 // @description Checks PRE and CODE tags in Summernote and ensures that their contents use HTML entities for proper display. // @author Salvatos // @license MIT // @match https://kanka.io/* // @match https://marketplace.kanka.io/* // @icon https://www.google.com/s2/favicons?domain=kanka.io // @run-at document-end // ==/UserScript== // Wait for Summernote to initialize $('#entry').on('summernote.init', function() { // Grab node tree from visual editor var masterNode = document.querySelector('#entry + .note-editor .note-editable'); // Find CODEs and PREs masterNode.querySelectorAll(":is(pre, code)").forEach((domObject) => { domObject.replaceChildren(domObject.innerHTML); // Exclude ' < ' and ' > ' for CSS and comparison operators domObject.textContent = domObject.textContent.replace(/ < /g, " < ").replace(/ > /g, " > "); }); // Apply changes to master copy in case of immediate save or switch to code view document.getElementById('entry').value = masterNode.innerHTML; // BUG: for some reason, this causes changes made in code view to be discarded if you don’t switch back to visual first, so let’s bring back our good old code view save fix... $('#entry').on('summernote.change.codeview', function(we, contents, $editable) { $(this).val(contents); }); });