Kanka Summernote Code View Save Fix

Correctly saves changes made while in code view in the Summernote editor.

目前為 2021-07-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Kanka Summernote Code View Save Fix
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Correctly saves changes made while in code view in the Summernote editor.
// @author       Salvatos
// @match        https://kanka.io/*/edit*
// @match        https://kanka.io/*/create*
// @icon         https://www.google.com/s2/favicons?domain=kanka.io
// @grant        none
// @run-at       document-end
// ==/UserScript==

async function fixCodeEditor() {
    // Wait for Summernote to finish initializing
    while(!document.querySelector(".note-codable")) {
        console.log("Waiting for Summernote.");
        await new Promise(r => setTimeout(r, 100));
    }
    console.log("Ready.");

    // Add input event to code editor
    var codeEditor = document.getElementsByClassName('note-codable')[0];
    codeEditor.addEventListener('input', ()=>{
        // Copy code editor’s value to Summernote’s hidden textarea
        document.getElementById('entry').value = codeEditor.value;
    });
}
fixCodeEditor();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址