Pretraži podršku

Izbjegni prevare podrške. Nikad te nećemo tražiti da nas nazoveš, da nam pošalješ telefonski broj ili da podijeliš osobne podatke. Prijavi sumnjive radnje pomoću opcije „Prijavi zlouporabu”.

Saznaj više

Need Help with Firefox Webextension!

  • 1 odgovor
  • 1 ima ovaj problem
  • 4 prikaza
  • Posljednji odgovor od 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>'; }

Svi odgovori (1)

more options

Problem is it doesn't display enable or disable,