opt xpath

This commit is contained in:
jianxin committed 2024-12-18 08:41:50 +08:00
1 parent 3f045f11e8
commit 7fb6d04b19
6 files changed
+358 -358

No files matched your search

+32 -32
View File
@@ -1,32 +1,32 @@
let isCopyModeEnabled = false;
chrome.action.onClicked.addListener(function (tab) {
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: toggleCopyMode
});
});
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.action === 'toggleCopyMode') {
isCopyModeEnabled = !isCopyModeEnabled;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'toggleCopyMode' }, function (response) {
sendResponse({ copyModeEnabled: isCopyModeEnabled });
});
});
return true; // Keep the message channel open for sendResponse
} else if (request.action === 'getCopyModeStatus') {
sendResponse({ copyModeEnabled: isCopyModeEnabled });
}
});
function toggleCopyMode() {
chrome.runtime.sendMessage({ action: 'toggleCopyMode' }, function (response) {
if (response.copyModeEnabled) {
console.log('Copy mode enabled');
} else {
console.log('Copy mode disabled');
}
});
}
let isCopyModeEnabled = false;
chrome.action.onClicked.addListener(function (tab) {
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: toggleCopyMode
});
});
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.action === 'toggleCopyMode') {
isCopyModeEnabled = !isCopyModeEnabled;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'toggleCopyMode' }, function (response) {
sendResponse({ copyModeEnabled: isCopyModeEnabled });
});
});
return true; // Keep the message channel open for sendResponse
} else if (request.action === 'getCopyModeStatus') {
sendResponse({ copyModeEnabled: isCopyModeEnabled });
}
});
function toggleCopyMode() {
chrome.runtime.sendMessage({ action: 'toggleCopyMode' }, function (response) {
if (response.copyModeEnabled) {
console.log('Copy mode enabled');
} else {
console.log('Copy mode disabled');
}
});
}