Spaces:
Running
Running
Create save-to-google/userscript.js
Browse files
src/addons/addons/save-to-google/userscript.js
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default async ({ addon, console, msg }) => {
|
2 |
+
while (true) {
|
3 |
+
const elem = await addon.tab.waitForElement('div[class*="menu-bar_file-group"] > div:last-child:not(.sa-modal)', {
|
4 |
+
markAsSeen: true,
|
5 |
+
reduxEvents: ["scratch-gui/mode/SET_PLAYER", "fontsLoaded/SET_FONTS_LOADED", "scratch-gui/locales/SELECT_LOCALE"],
|
6 |
+
});
|
7 |
+
|
8 |
+
const showModal = () => {
|
9 |
+
const { backdrop, container, content, closeButton, remove } = addon.tab.createModal(msg("modal-title"), {
|
10 |
+
isOpen: true,
|
11 |
+
useEditorClasses: true,
|
12 |
+
});
|
13 |
+
|
14 |
+
container.classList.add("customModal");
|
15 |
+
content.classList.add("customModalContent");
|
16 |
+
content.innerHTML = `
|
17 |
+
<h2>${msg("modal-heading")}</h2>
|
18 |
+
<p>${msg("modal-description")}</p>
|
19 |
+
<button id="modalCloseButton">${msg("close")}</button>
|
20 |
+
`;
|
21 |
+
|
22 |
+
document.getElementById("modalCloseButton").addEventListener("click", remove);
|
23 |
+
backdrop.addEventListener("click", remove);
|
24 |
+
closeButton.addEventListener("click", remove);
|
25 |
+
};
|
26 |
+
|
27 |
+
let modalElem = document.createElement("div");
|
28 |
+
modalElem.className = "sa-modal " + elem.className;
|
29 |
+
modalElem.textContent = msg("open-modal");
|
30 |
+
modalElem.addEventListener("click", showModal);
|
31 |
+
elem.parentElement.appendChild(modalElem);
|
32 |
+
}
|
33 |
+
};
|