// ==UserScript==
// @name              T-notion-双击打开
// @author            tianyunperfect
// @description       简介
// @version           1.0.0
// @update            2021-07-08 16:16:14
// @include           https://*.notion.so/*
// @require           https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/monkey/util.js?a=2022年06月11日

// ==/UserScript==
(async () => {
    addJQ();

    function openNewTab(ev) {
        let block_id = jQuery(ev.target).parents("div[data-block-id]").eq(0).attr('data-block-id');
        block_id = block_id.replaceAll("-", "");
        window.open("https://www.notion.so/tianyunperfect/" + block_id, "_blank");
    }

    function changeS(ev) {
        let triangle = jQuery(ev.target).parents("div[data-block-id]")[0].querySelector(".pseudoSelection");
        if (triangle && triangle.querySelector(".triangle")) {
            triangle.querySelector('[role="button"]').click();
        }
    }

    setInterval(() => {
        let item = jQuery("div[data-block-id]");
        item.off("dblclick").on("dblclick", (ev) => {
            ev.stopPropagation();
            changeS(ev)
        });
        item.off("click").on("click", (ev) => {
            if (ev.metaKey) {
                ev.stopPropagation();
                changeS(ev)
            }
        });
    }, 2000)

})();
