We're calling on all EU-based Mozillians with iOS or iPadOS devices to help us monitor Apple’s new browser choice screens. Join the effort to hold Big Tech to account!

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

Need Help with Firefox Webextension!

  • 1 réponse
  • 1 a ce problème
  • 4 vues
  • Dernière réponse par 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>'; }

Toutes les réponses (1)

more options

Problem is it doesn't display enable or disable,