I try to create a WebExtension which do some things if it's on a specific site in a specific folder. I tried to recognice the site and the subfolder like this:
var on = true;
//This function checks if the current site is Google after something was searched
function check_if_engine() {
var loc = window.location.href;
if (loc.includes("google")) {
alert("Includes google");
if (log.includes("search?")) {
return true;
}
return false;
}
return false;
//...
function start_all() {
if (on) {
alert("Addon activated!");
if (check_if_engine()) {
alert("Website is Google");
//...
}
//Checks if the tab loaded a new URL
browser.tabs.onUpdated.addListener(start_all);
mainfest.json:
{
"manifest_version": 2,
"name": "Is this a Google Search?",
"version": "1.0",
"description": "This Addon tells you if you are on Google Search Page",
"icons": {
"48": "icon/icon.png"
},
"browser_action": {
"default_icon": "icon/icon.png",
"default_title": "Is this a Google search?"
},
"permissions": [
"activeTab"
],
"background": {
"scripts": ["main.js"]
}
}
There aren't any other background/content scripts.
But if I tried it, there was no message, which said that "Includes google" and the returned value was "false" even if I loaded the Google Page (Instant Search disabled) and searched for something. May you can help me.
Thanks