Upload files to "/"

This commit is contained in:
2025-07-26 14:32:08 +02:00
parent 83b441b7c5
commit 511a371e78
2 changed files with 101 additions and 0 deletions

49
background.js Normal file
View File

@@ -0,0 +1,49 @@
// Extension initialization
chrome.runtime.onInstalled.addListener(() => {
console.log("Word Replacer Addon installed.");
// Set default replacements if they don't already exist
chrome.storage.local.get('wordReplacements', (data) => {
if (!data.wordReplacements) {
chrome.storage.local.set({
wordReplacements: {
"oldWord1": "newWord1",
"oldWord2": "newWord2",
"oldWord3": "newWord3"
}
});
}
});
});
// Data cleanup when possible
function cleanupStorageData() {
chrome.storage.local.clear(() => {
console.log("Extension storage cleared.");
});
}
// For Firefox we can use onSuspend which is called when the extension process
// is terminated (can happen on deactivation or uninstallation)
chrome.runtime.onSuspend.addListener(() => {
console.log("Word Replacer Addon terminated.");
// Uncomment the following line if you want to remove all data on suspension
// cleanupStorageData();
});
// Add a command to manually clean the data
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === 'getReplacements') {
chrome.storage.local.get('wordReplacements', (data) => {
sendResponse(data.wordReplacements || {});
});
return true; // Required for asynchronous sendResponse
}
// New command to clean the data
if (message.action === 'clearStorageData') {
cleanupStorageData();
sendResponse({success: true});
return true;
}
});

52
manifest.json Normal file
View File

@@ -0,0 +1,52 @@
{
"manifest_version": 2,
"name": "Word Replacer",
"version": "1.0.0",
"description": "Replaces specific words in web pages with customizable alternatives.",
"author": "krypt77",
"homepage_url": "https://gitea.it/krypt77/Firefox-Word-Replacer-Addon",
"permissions": [
"activeTab",
"storage",
"tabs"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content_scripts/replacer.js"],
"run_at": "document_end"
}
],
"icons": {
"48": "icons/icon-48.png",
"96": "icons/icon-96.png"
},
"browser_action": {
"default_icon": {
"48": "icons/icon-48.png"
},
"default_title": "Word Replacer",
"default_popup": "popup/options.html"
},
"options_ui": {
"page": "popup/options.html",
"open_in_tab": true
},
"applications": {
"gecko": {
"id": "word-replacer@krypt77.com",
"strict_min_version": "57.0"
}
}
}