Created
June 25, 2018 22:59
-
-
Save ninoseki/1c7cb8e9550f0c0799a83894f7bae760 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('selectionchange', () => { | |
const selection: string = window.getSelection().toString().trim(); | |
chrome.runtime.sendMessage({ | |
request: 'updateContextMenu', | |
target: selection, | |
}); | |
}); | |
const links = document.getElementsByTagName('a'); | |
for (const link of links) { | |
const RIGHT = 2; | |
link.addEventListener('mousedown', (e) => { | |
if (e.button === RIGHT) { | |
const selection = link.getAttribute('href'); | |
if (selection !== null) { | |
chrome.runtime.sendMessage({ | |
request: 'updateContextMenu', | |
target: selection, | |
}); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment