用于删除 Google Sheet 的书签

Bookmarklet to delete a Google Sheet

我正在寻找一个小书签,它将删除当前的 Google Sheet(而不是 "Move to bin" 菜单选项)。我可以从 JavaScript 中看到 "File">"Move to bin" 代码如下所示:

Ih = Ak(uk("docs-trash").label("Move to bin").Ea(765), "trash").dc("bin | delete | remove ||").build();

我认为解决方案可能是: javascript: document.getElementById("docs-trash").click();

我这样做是不是走错了路?

希望这样的内容对您有所帮助:

javascript:(function() {
    var eltMove = document.querySelector('#\:b2>div>span');
    fireMouseEvent(document.querySelector('#docs-file-menu'), 'mousedown');
    fireMouseEvent(eltMove, 'mousedown');
    fireMouseEvent(eltMove, 'mouseup');
    fireMouseEvent(eltMove, 'mouseup');

    function fireMouseEvent(eltTarget, myEvent) {
        var screenX, screenY, clientX, clientY;
        var event = document.createEvent('MouseEvents');
        event.initMouseEvent(myEvent, true, true, window, 1, screenX, screenY, clientX, clientY, false, false, false, false, 0, null);
        eltTarget.dispatchEvent(event);
    }
})();