Skip to content

Instantly share code, notes, and snippets.

View adityabhaskar's full-sized avatar
👣
à pied

Aditya adityabhaskar

👣
à pied
View GitHub Profile
@adityabhaskar
adityabhaskar / selection.js
Created September 15, 2018 06:50
Check if selection is a link
const selection = getSelection();
const isALink = selection.type.toLowerCase() == "range") && // Selection is a range, and
selection.anchorNode == selection.focusNode && // Starts & finishes in the same node, and
selection.anchorOffset == 0 && // Starts at beginning of the node, and
selection.focusOffset == selection.focusNode.textContent.length && // Finishes at end of the node, and
(selection.anchorNode.nodeName.toLowerCase() == 'a' || // Node is of type 'a' (link/anchor), or
selection.anchorNode.parentElement.nodeName.toLowerCase() == 'a') // Node parent is of type 'a' (link/anchor)
@adityabhaskar
adityabhaskar / aboutme.md
Created January 23, 2015 01:22
What Am I?

Dad to a weapons-grade face-licker dog,

Partner to a hyper-energetic, monica-esque girl,

Runner,

Cyclist,

Hiker,

Keybase proof

I hereby claim:

  • I am adityabhaskar on github.
  • I am adityabhaskar (https://keybase.io/adityabhaskar) on keybase.
  • I have a public key whose fingerprint is 5CC9 D757 A7A1 E844 EB56 4ACC 5027 D117 846E 7CAE

To claim this, I am signing this object: