V1
This commit is contained in:
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Goodnotes Export All
|
||||
### This a small userscript to add the ability to export all documents visible on the page at once.
|
||||
### This is useful to bulk export folders
|
||||
72
userscript.js
Normal file
72
userscript.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// ==UserScript==
|
||||
// @name Goodnotes Export All
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 2024-12-14
|
||||
// @description Button to export all documents in current folder as pdf
|
||||
// @author AINDUSTRIES
|
||||
// @match https://web.goodnotes.com/home
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=goodnotes.com
|
||||
// @grant none
|
||||
// @downloadURL https://raw.githubusercontent.com/A-INDUSTRIES/BetterMoodle/main/userscript.js
|
||||
// @updateURL https://raw.githubusercontent.com/A-INDUSTRIES/BetterMoodle/main/userscript.js
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
addButtonToUi();
|
||||
})();
|
||||
|
||||
function addButtonToUi() {
|
||||
let button = document.getElementById("library-top-bar-new-button");
|
||||
if (button === null) {
|
||||
setTimeout(() => {addButtonToUi();}, 100);
|
||||
}
|
||||
let newButton = document.createElement("button");
|
||||
let separator = document.createElement("div");
|
||||
newButton.textContent = "Export All";
|
||||
newButton.className = "sc-11sl4ep-0 sc-11sl4ep-3 sc-11sl4ep-4 TWXtr jvQTin dtaHTu sc-1w3an16-5 jcbUh";
|
||||
newButton.style.color = "white";
|
||||
newButton.style.fontSize = "85%";
|
||||
separator.className = "sc-1w3an16-8 dAJWSd";
|
||||
button.parentNode.insertBefore(newButton, button.nextSibling);
|
||||
button.parentNode.insertBefore(separator, button.nextSibling);
|
||||
newButton.addEventListener("click", () => {
|
||||
let allDocuments = getAllDocuments();
|
||||
clickExportOnAllDocuments(allDocuments);
|
||||
})
|
||||
}
|
||||
|
||||
function getAllDocuments () {
|
||||
let allDocuments = [];
|
||||
let rootNode = document.getElementById("libraryViewDocumentGrid");
|
||||
let childNodes = rootNode.childNodes;
|
||||
childNodes.forEach((childNode) => {
|
||||
// If the elements are documents they should not have an id.
|
||||
if (childNode.getAttibute("id") === null) {
|
||||
let child = childNode.firstChild;
|
||||
allDocuments.push(child);
|
||||
}
|
||||
})
|
||||
return allDocuments;
|
||||
}
|
||||
|
||||
function clickExportOnAllDocuments(allDocuments) {
|
||||
let i = 0;
|
||||
allDocuments.forEach((doc) => {
|
||||
let event = new MouseEvent('contextmenu', {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
view: window,
|
||||
button: 2
|
||||
});
|
||||
setTimeout(() => {
|
||||
doc.dispatchEvent(event);
|
||||
// Then get the context menu to click on "Export" after short delay
|
||||
let exportButton = document.getElementById("exportPdfButton");
|
||||
exportButton.click();
|
||||
// Click out of context menu to allow other context menu to pop
|
||||
let outer = document.getElementById("fullScreenModalDismissibleArea");
|
||||
outer.click();
|
||||
}, 500*i);
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user