Greasy Fork

来自缓存

Greasy Fork is available in English.

Remove editability on click from trello card details

Removes click to edit behavior from Trello card detail descriptions within modals.

当前为 2019-12-10 提交的版本,查看 最新版本

// ==UserScript==
// @name          Remove editability on click from trello card details
// @namespace     https://github.com/danbozaru
// @version       1.0.1
// @description   Removes click to edit behavior from Trello card detail descriptions within modals.
// @author        [email protected]
// @include       https://trello.com/*
// @run-at        document-start
// @grant         GM_log
// ==/UserScript==

(function(win) {
    'use strict';

    var listeners = [],
        doc = win.document,
        MutationObserver = win.MutationObserver || win.WebKitMutationObserver,
        observer;

    function ready(selector, fn) {
        // Store the selector and callback to be monitored
        listeners.push({
            selector: selector,
            fn: fn
        });
        if (!observer) {
            // Watch for changes in the document
            observer = new MutationObserver(check);
            observer.observe(doc.documentElement, {
                childList: true,
                subtree: true
            });
        }
        // Check if the element is currently in the DOM
        check();
    }

    function check() {
        // Check the DOM for elements matching a stored selector
        for (var i = 0, len = listeners.length, listener, elements; i < len; i++) {
            listener = listeners[i];
            // Query for elements matching the specified selector
            elements = doc.querySelectorAll(listener.selector);
            for (var j = 0, jLen = elements.length, element; j < jLen; j++) {
                element = elements[j];
                // Make sure the callback isn't invoked with the
                // same element more than once
                if (!element.ready) {
                    element.ready = true;
                    // Invoke the callback with the element
                    listener.fn.call(element, element);
                }
            }
        }
    }

    // Expose `ready`
    win.ready = ready;
})(this);

window.ready('.window-module .editable', node => {
    node.classList.remove('editable');
});