Commit 4103d788 authored by insert's avatar insert 🎺

Update google-contacts.user.js

parent 3738af47
/**
* @name google_contacts_scraper
* @description Scrapes contacts from a given page on Google Contacts
* @author insert <insrt.uk>
*
* == Instructions ==
* 1. Go to Google Contacts
* 2. Run script
* 3. Collect data by scrolling and loading all contacts
* 4. Run collect(); to get data set
*/
let set = {};
(() => {
var targetNode = document.querySelector("#yDmH0d");
var observerOptions = {
childList: true,
attributes: false,
subtree: true
};
let callback = (mutationList, observer) => {
mutationList.forEach((mutation) => {
switch (mutation.type) {
case 'childList':
mutation.addedNodes.forEach(x => {
if (x.className == "XXcuqd") {
let p = x.innerText;
if (p.startsWith('\t')) p = p.substring(1);
let r = p.split('\t');
set[r[0]] = r[1];
}
});
break;
}
});
};
var observer = new MutationObserver(callback);
observer.observe(targetNode, observerOptions);
})();
function collect() {
let d = new Date();
return JSON.stringify({
_comment: "Generated using Google Contacts scraper script [v1].",
year: d.getMonth() > 7,
generated: '' + d,
data: set
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment