Dynalist image pasting

Paste into top left Input Box then paste again into the list in app and press enter

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

Advertisement:

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

Advertisement:

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Dynalist image pasting
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Paste into top left Input Box then paste again into the list in app and press enter
// @author       You
// @match        https://dynalist.io/*
// @grant        none
// ==/UserScript==

function GM_addStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css.replace(/;/g, ' !important;');
    head.appendChild(style);
}

(function() {
    GM_addStyle('img { width:100% }');
    $('body').append('<div class="AppHeader-pastebox" style="left: 18px; top: 2px;position: absolute; z-index:1000"><input data-lpignore="true" autocomplete="off" style="font-size: 16px; padding: 3px 0"></div>')
    $('.AppHeader-pastebox').on('paste', function (ev) {
        ev.preventDefault()
        ev.stopPropagation()
        var clipboardData = ev.originalEvent.clipboardData;
        if (clipboardData) {
            if (clipboardData.items.length == 0)
                return;
            $.each(clipboardData.items, function (i, item) {
                if (item.type.indexOf("image") !== -1) {
                    insertBinaryImage(item.getAsFile(),ev);
                }
            });
            return false;
        }
    });

    // Inserts a base64-encoded image to the editor.
    function insertBinaryImage(file, ev) {
        var reader = new FileReader();
        reader.addEventListener('loadend', function () {
            $('.modal-container.file-upload-upsell.is-shown').removeClass('is-shown')
            let text = `![](${reader.result})`;
            navigator.clipboard.writeText(text).then(function() {
                $('.AppHeader-pastebox input').val('Copied!');
            }, function(err) {
                console.error('Async: Could not copy text: ', err);
            });
        });
        reader.readAsDataURL(file);
    }
})();