Merge pull request #24 from minj/improve-link-detection

improve link detection in notify-link-clicks
This commit is contained in:
wbamberg
2016-01-06 07:16:17 -08:00
2 changed files with 15 additions and 7 deletions

View File

@@ -1,9 +1,13 @@
window.addEventListener("click", notifyExtension);
function notifyExtension(e) {
console.log("content script sending message");
if (e.target.tagName != "A") {
return;
var target = e.target;
while ((target.tagName != "A" || !target.href) && target.parentNode) {
target = target.parentNode;
}
chrome.runtime.sendMessage({"url": e.target.href});
if (target.tagName != "A")
return;
console.log("content script sending message");
chrome.runtime.sendMessage({"url": target.href});
}

View File

@@ -1,9 +1,13 @@
window.addEventListener("click", notifyExtension);
function notifyExtension(e) {
if (e.target.tagName != "A") {
return;
var target = e.target;
while ((target.tagName != "A" || !target.href) && target.parentNode) {
target = target.parentNode;
}
if (target.tagName != "A")
return;
console.log("content script sending message");
chrome.runtime.sendMessage({"url": e.target.href});
chrome.runtime.sendMessage({"url": target.href});
}