Skip to content

Instantly share code, notes, and snippets.

@awitherow
Last active July 17, 2022 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awitherow/3e593815f19f55e5be81c115b31ec1f9 to your computer and use it in GitHub Desktop.
Save awitherow/3e593815f19f55e5be81c115b31ec1f9 to your computer and use it in GitHub Desktop.
Extract Social Media Profiles and Emails from Web Page
(function () {
const links = Array.prototype.slice.call(document.getElementsByTagName("a")).filter(item =>
["twitter.com/", "facebook.com/", "youtube.com/", "pinterest.com/", "linkedin.com/in", ]
).map(item => item.href).filter(Boolean)
const emails = extractEmails(document.getElementsByTagName('html')[0].innerHTML)
const everything = [...links, ...emails]
const save = function (data, filename) {
if (!data) {
console.error("Console.save: No data");
return;
}
if (!filename) filename = "console.json";
if (typeof data === "object") {
data = JSON.stringify(data, undefined, 4);
}
var blob = new Blob([data], { type: "text/json" }),
a = document.createElement("a");
var e = new MouseEvent("click", {
view: window,
bubbles: true,
cancelable: false,
});
a.download = filename;
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = ["text/json", a.download, a.href].join(":");
a.dispatchEvent(e);
};
save(everything, document.title);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment