搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Need Help with Firefox Webextension!

  • 1 个回答
  • 1 人有此问题
  • 4 次查看
  • 最后回复者为 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>'; }

所有回复 (1)

more options

Problem is it doesn't display enable or disable,