Initial commit
This commit is contained in:
48
extension/background.js
Normal file
48
extension/background.js
Normal file
@@ -0,0 +1,48 @@
|
||||
// Background script for service worker
|
||||
// Currently minimal, can be extended for additional functionality
|
||||
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
console.log('Facebook Post Tracker extension installed');
|
||||
|
||||
// Set default profile if not set
|
||||
chrome.storage.sync.get(['profileNumber'], (result) => {
|
||||
if (!result.profileNumber) {
|
||||
chrome.storage.sync.set({ profileNumber: 1 });
|
||||
}
|
||||
});
|
||||
|
||||
// Create context menu for manual post parsing
|
||||
chrome.contextMenus.create({
|
||||
id: 'fb-tracker-reparse',
|
||||
title: 'FB Tracker: Post neu parsen',
|
||||
contexts: ['all'],
|
||||
documentUrlPatterns: ['*://*.facebook.com/*']
|
||||
});
|
||||
});
|
||||
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
||||
if (info.menuItemId === 'fb-tracker-reparse') {
|
||||
chrome.tabs.sendMessage(tab.id, {
|
||||
type: 'reparsePost',
|
||||
x: info.pageX || 0,
|
||||
y: info.pageY || 0
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message && message.type === 'captureScreenshot') {
|
||||
const windowId = sender && sender.tab ? sender.tab.windowId : chrome.windows.WINDOW_ID_CURRENT;
|
||||
|
||||
chrome.tabs.captureVisibleTab(windowId, { format: 'jpeg', quality: 80 }, (imageData) => {
|
||||
if (chrome.runtime.lastError) {
|
||||
sendResponse({ error: chrome.runtime.lastError.message });
|
||||
return;
|
||||
}
|
||||
|
||||
sendResponse({ imageData });
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Reference in New Issue
Block a user