javascript - Chrome Extension That Launches From An HREF click? -


we're building chrome extension our corporate environment. when user browsing web, if click on link, extension should view link , prompt user warning if link site have business relationship , warn them (and in few rare circumstances prevent them going link).

we created extension that's appears button on toolbar , when user clicks on popup appears. that's good. want rid of button , have invoked when user clicks on link on whatever webpage they're viewing. extension read link , decide if should prompt user. how done though? how can make extension override href clicks?

(note, we're not concerned when type in web address manually or click on link outlook, reasons beyond scope of question)

thanks

this simple do. inject content script onto every web page this:

var anchors = document.queryselectorall('a') (var i=0; i<anchors.length; i++) {     anchors[i].addeventlistener('click',function(event) {         if ( /* check here if partner link */ ) {             // issue warning user             event.preventdefault()             event.stoppropagation()         }     }) } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -