Skip to content

Commit

Permalink
Merge pull request #19 from IbrahimMohammed47/ff-mv2
Browse files Browse the repository at this point in the history
Fix firefox host permissions
  • Loading branch information
seif authored Apr 1, 2024
2 parents 69d754b + ad0c693 commit e7171f3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
15 changes: 15 additions & 0 deletions browsers-adapters/firefox/worker-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function sendMessageToTab(tabId, msgObj) {
return browser.tabs.sendMessage(tabId, msgObj);
}

export function setIcon(details) {
return browser.browserAction.setIcon(details);
}

export function executeScript(injection) {
return browser.scripting.executeScript(injection);
}

export function cacheSet(keyValuesObj) {
return browser.storage.local.set(keyValuesObj);
}
18 changes: 18 additions & 0 deletions browsers-adapters/firefox/worker-listeners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { handleTabVisit } from "../../background.js";
import * as actions from "./worker-actions.js";

// Listen when user switches to a tab (activates it)
browser.tabs.onActivated.addListener((activeInfo) => {
browser.tabs.get(activeInfo.tabId, (tab) => {
if (tab && tab.url) {
handleTabVisit(actions, activeInfo.tabId, tab.url);
}
});
});

// Listen for tab updates (when the URL changes)
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (tabId && changeInfo.status === "complete") {
handleTabVisit(actions, tabId, tab.url);
}
});
4 changes: 2 additions & 2 deletions manifest.chrome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Boycott-Z",
"version": "0.2.1",
"description": "",
"version": "0.2.2",
"description": "Adds a browser add-on icon that turns red when viewed site or product is on the boycott list.",
"permissions": [
"tabs",
"activeTab",
Expand Down
24 changes: 10 additions & 14 deletions manifest.firefox.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
{
"name": "Boycott-Z",
"version": "0.2.1",
"description": "",
"version": "0.2.2",
"description": "Adds a browser add-on icon that turns red when viewed site or product is on the boycott list.",
"permissions": [
"<all_urls>",
"tabs",
"activeTab",
"scripting",
"storage"
],
"host_permissions": [
"<all_urls>"
],
"icons": {
"48": "icons/green-triangle-128.png"
},
"web_accessible_resources": [
{
"resources": [],
"matches": [
"<all_urls>"
]
}
"popup/*.*"
],
"action": {
"browser_action": {
"default_icon": {
"16": "icons/green-triangle-128.png",
"48": "icons/green-triangle-128.png",
Expand All @@ -30,7 +26,7 @@
},
"background": {
"scripts": [
"browsers-adapters/chrome/worker-listeners.js"
"browsers-adapters/firefox/worker-listeners.js"
],
"type": "module"
},
Expand All @@ -39,5 +35,5 @@
"id": "{17a15a43-7d2b-4796-b9a9-1901da7f6335}"
}
},
"manifest_version": 3
"manifest_version": 2
}
12 changes: 7 additions & 5 deletions popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// popup.js

chrome.storage.local.get(["boycottZItem"]).then((result) => {
if (!('browser' in self)) {
self.browser = self.chrome;
}

browser.storage.local.get(["boycottZItem"]).then((result) => {
const boycottZItem = result.boycottZItem
if (!boycottZItem) {
return window.close()
Expand Down Expand Up @@ -44,11 +48,9 @@ chrome.storage.local.get(["boycottZItem"]).then((result) => {
if (proof) {
document.getElementById("boycottZProof").addEventListener('click', (event) => {
let ur = event.target.getAttribute('href')
chrome.tabs.create({ url: ur });
browser.tabs.create({ url: ur });
return false;
})
// $('body').on('click', 'a', function(){
// return false;
// });
}

});
Expand Down

0 comments on commit e7171f3

Please sign in to comment.