Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Need Help with Firefox Webextension!

  • 1 resposta
  • 1 has this problem
  • 4 views
  • Last reply by SR-x

more options

Hi,

   I am making a web extension for Firefox. I am stuck in a problem on popup that will show user if extension is enable or disable.

It will automatically enable or disable by matching the users current tab URL.

Here is the js code:

chrome.tabs.query({currentWindow: true, active: true}, function(tabs){

   var url = tabs[0].url;

})

var domain = url;

var url = domain;

   if( url.indexOf('https://') >=0){
    


   //find & remove protocol (http, ftp, etc.) and get domain
   if (url.indexOf("://") > -1) {
       domain = url.split('/')[2];
   }
   else {
       domain = url.split('/')[0];
   }
   //find & remove port number
   domain = domain.split(':')[0];

//this removes the anchor at the end, if there is one url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#")); //this removes the query after the file name, if there is one url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?")); //this removes everything before the last slash in the path url = url.substring(url.lastIndexOf("/") + 1, url.length);


   if (domain == "www.youtube.com") {
       
   if (url == "watch") {
content.document.getElementById("main").innerHTML = '
Enabled
'; //var main_de = '
Enabled
';
   } else {
content.document.getElementById("main").innerHTML = '
Disabled
'; //var main_de = '
Disabled
';
   }
   } else {
content.document.getElementById("main").innerHTML = '
Disabled
'; //var main_de = '
Disabled
';
   }

} else{

content.document.getElementById("main").innerHTML = '
Disabled
';

}

Hi, I am making a web extension for Firefox. I am stuck in a problem on popup that will show user if extension is enable or disable. It will automatically enable or disable by matching the users current tab URL. Here is the js code: chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ var url = tabs[0].url; }) var domain = url; var url = domain; if( url.indexOf('https://') >=0){ //find & remove protocol (http, ftp, etc.) and get domain if (url.indexOf("://") > -1) { domain = url.split('/')[2]; } else { domain = url.split('/')[0]; } //find & remove port number domain = domain.split(':')[0]; //this removes the anchor at the end, if there is one url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#")); //this removes the query after the file name, if there is one url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?")); //this removes everything before the last slash in the path url = url.substring(url.lastIndexOf("/") + 1, url.length); if (domain == "www.youtube.com") { if (url == "watch") { content.document.getElementById("main").innerHTML = '<div class="green">Enabled</div>'; //var main_de = '<div class="green">Enabled</div>'; } else { content.document.getElementById("main").innerHTML = '<div class="red">Disabled</div>'; //var main_de = '<div class="red">Disabled</div>'; } } else { content.document.getElementById("main").innerHTML = '<div class="red">Disabled</div>'; //var main_de = '<div class="red">Disabled</div>'; } } else{ content.document.getElementById("main").innerHTML = '<div class="red">Disabled</div>'; }

All Replies (1)

more options

Problem is it doesn't display enable or disable,