Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

Need Help with Firefox Webextension!

  • 1 trả lời
  • 1 gặp vấn đề này
  • 9 lượt xem
  • Trả lời mới nhất được viết bởi 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>'; }

Tất cả các câu trả lời (1)

more options

Problem is it doesn't display enable or disable,