Skip to content

Instantly share code, notes, and snippets.

@mohanmca
Created April 4, 2018 15:37
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 mohanmca/481056956ca618a3b21a2b3a0d156f11 to your computer and use it in GitHub Desktop.
Save mohanmca/481056956ca618a3b21a2b3a0d156f11 to your computer and use it in GitHub Desktop.
YcombinatorLinkCounter.md
const container = document.evaluate('//a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE , null)
const items = Array.from(Array(container.snapshotLength).keys())
const _links = items.map(i => container.snapshotItem(i).innerHTML).filter(text => text.indexOf("http")!=-1)
const links = _links.sort().filter((e,i,a) => a.indexOf(e)==i)
console.log("Unique links \n" + links.join("\n"))
let map = {}
_links.sort().map(link => link.substring(0,100)).forEach(link => map[link] = (map[link] || 0) + 1)
Object.entries(map).sort(kv => kv[1]).map(kv =>  kv[1].toString().padEnd(4) + kv[0]).join("\n")
@mohanmca
Copy link
Author

mohanmca commented Apr 4, 2018

copy paste the above code in console. (You can find console of the browser by pressing F12)

@blurredart
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment