I'm looking for a bookmarklet which will delete the current Google Sheet (rather than the "Move to bin"
menu option). I can see from the JavaScript that the "File">"Move to bin"
code looks like this:
Ih = Ak(uk("docs-trash").label("Move to bin").Ea(765), "trash").dc("bin | delete | remove ||").build();
I thought that the solution might be:
javascript: document.getElementById("docs-trash").click();
Am I going down the wrong route trying to do it this way?
I hope something like this may be helpful to you:
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);
}
})();