Commit 1f5a1271 authored by insert's avatar insert 🎺

Inject elements instead of rely on console

parent f8a8c4d5
......@@ -6,7 +6,7 @@
// @author insert
// @match https://contacts.google.com/*
// @grant none
// @run-at document-start
// @run-at document-end
// ==/UserScript==
/**
......@@ -18,12 +18,15 @@
* 1. Go to Google Contacts
* 2. Run script
* 3. Collect data by scrolling and loading all contacts
* 4. Run collect(); to get data set
* 4. Press button at the top of the site
*/
let set = {};
(() => {
document.onreadystatechange = function () {
if (document.readyState === "complete") {
(() => {
var targetNode = document.querySelector("#yDmH0d");
var observerOptions = {
......@@ -52,9 +55,9 @@ let set = {};
var observer = new MutationObserver(callback);
observer.observe(targetNode, observerOptions);
})();
})();
function collect() {
function collect() {
let d = new Date();
return JSON.stringify({
_comment: "Generated using Google Contacts scraper script [v1].",
......@@ -62,4 +65,18 @@ function collect() {
generated: '' + d,
data: set
});
}
(() => {
let el = document.createElement('a');
el.innerText = "click to export and console.log data set";
el.addEventListener('click', () => {
console.log(collect());
return false;
});
document.querySelector('.gb_ne').append(el);
})();
}
}
\ 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