-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle_keep_backup.user.js
More file actions
53 lines (44 loc) · 2.15 KB
/
Copy pathgoogle_keep_backup.user.js
File metadata and controls
53 lines (44 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ==UserScript==
// @name Google Keep Backup
// @namespace aljgom
// @version 0.1
// @description Deselects all products and selects Google Keep to back it up
// @author aljgom
// @match https://takeout.google.com/settings/takeout
// @match https://takeout.google.com/settings/takeout/
// @match https://bitly.com/a/warning?hash=2QQtLmu*
// @grant none
// ==/UserScript==
(async function(){
'use strict';
let url = document.location.toString();
let sleep = ms => new Promise(resolve=>setTimeout(resolve,ms));
if(url.match('https://takeout.google.com')){
await sleep(1000);
document.getElementsByClassName('ksBjEc')[1].click(); // click on select none
// Find the toogle for Keep by reading all the names.
var keepBox = null;
HTMLCollection.prototype.forEach = Array.prototype.forEach;
document.getElementsByClassName('gGfIad').forEach(el=>{ // selector for whole row
if(el.children[1] && el.children[1].children[0]){ // make sure node has children
if(["Keep", "Notizen"].includes(el.children[1].children[0].innerText)){ // see if the name matches the list (Notizen = german Keep)
keepBox = el.children[2].children[0].children[0]; // keep checkbox
}
}
});
// Scroll to Google Keep toggle
keepBox.scrollIntoView();
window.scrollTo(0,window.scrollY-300); // scroll up a bit because keep is covered by bar
await sleep(1000);
keepBox.click();
// Add listener to 'select' button so that 'backup' button will be pressed automatically
document.getElementsByClassName('oFLoie')[0].children[0].addEventListener('click', async ()=>{
await sleep(1000);
document.getElementsByClassName('oFLoie')[1].children[0].click();
});
}
// Redirect bitly "warning" page to takeout
if(url.match('bitly')){ // Userscript match is for bitly.com/2QQtLmu
window.location = "https://takeout.google.com/settings/takeout/"
}
})();