Skip to content

Commit

Permalink
init test for get tab and selection information
Browse files Browse the repository at this point in the history
  • Loading branch information
sailist committed Jun 8, 2024
1 parent f39fcb0 commit 1a04ad9
Show file tree
Hide file tree
Showing 4 changed files with 2,560 additions and 3,406 deletions.
8 changes: 8 additions & 0 deletions chrome-extension/lib/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ exampleThemeStorage.get().then(theme => {
});

console.log('background loaded');
console.log('background loaded 2');
console.log("Edit 'apps/chrome-extension/lib/background/index.ts' and save to reload.");

chrome.tabs.onActivated.addListener(({ tabId }) => {
const tab = chrome.tabs.get(tabId).then((value) => {
console.log(value);
});
});

2 changes: 1 addition & 1 deletion chrome-extension/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const manifest = Object.assign(
name: '__MSG_extensionName__',
version: packageJson.version,
description: '__MSG_extensionDescription__',
permissions: ['storage'].concat(sidePanelConfig.permissions),
permissions: ['storage', 'tabs', 'activeTab', "scripting"].concat(sidePanelConfig.permissions),
options_page: 'options/index.html',
background: {
service_worker: 'background.iife.js',
Expand Down
10 changes: 10 additions & 0 deletions pages/content/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@ import { toggleTheme } from '@lib/toggleTheme';
console.log('content script loaded');

void toggleTheme();

window.addEventListener("selectstart", (event) => {
// We only accept messages from ourselves
console.log(event);
console.log(document.getSelection()?.getRangeAt(0));
}, false);
window.addEventListener("copy", (event) => {
// We only accept messages from ourselves
console.log(document.getSelection()?.getRangeAt(0));
}, false);
Loading

0 comments on commit 1a04ad9

Please sign in to comment.