Skip to content

Commit

Permalink
fix: remove background.js for now as it is unsupported in Firefox
Browse files Browse the repository at this point in the history
At least not as a service worker, and providing different manifest files for a feature we don't even use sounds not very useful: mozilla/web-ext#2532
  • Loading branch information
rugk committed Oct 16, 2024
1 parent 3532b2d commit bd661f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion background.js

This file was deleted.

6 changes: 2 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"name": "Image Shuffler",
"version": "1.0",
"description": "Shuffle image paths on the current website",
"permissions": ["activeTab", "scripting"],
"background": {
"service_worker": "background.js"
},
"permissions": ["activeTab", "scripting", "tabs"],
"host_permissions": ["<all_urls>"],
"action": {
"default_popup": "popup.html"
},
Expand Down
16 changes: 11 additions & 5 deletions popup.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
document.getElementById('shuffle-btn').addEventListener('click', () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
function: shuffleImages
document.addEventListener('DOMContentLoaded', function () {
const shuffleBtn = document.getElementById('shuffle-btn');

shuffleBtn.addEventListener('click', () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
func: shuffleImages
});
});
});
});

function shuffleImages() {
console.info("shuffle images executed");

// Remove all source elements from the DOM
const sources = document.querySelectorAll('source');
sources.forEach(source => source.remove());
Expand Down

0 comments on commit bd661f2

Please sign in to comment.