+function open_link(url, in_new_tab) {
+ if (in_new_tab) {
+ open_tab(url);
+ return;
+ }
+
+ browser.tabs.query({active:true, currentWindow:true})
+ .then(
+ function(tabs) {
+ browser.tabs.executeScript(tabs[0].id, {file: '/icedeb-content.js'})
+ .then(
+ function(){
+ browser.tabs.sendMessage( tabs[0].id, {url:url} );
+ },
+ function(err){
+ console.log('Error executing script', err);
+ });
+
+ },
+ function(err) {
+ console.log('Error querying the active tab of the current window', err);
+ open_tab(url);
+ }
+ );
+}
+
+function link_clicked(e) {
+ if (e.target.tagName == 'a') {
+ open_link(e.target.href, e.button == 1);
+ e.preventDefault();
+ return false;
+ }
+