Skip to content

Commit

Permalink
0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
emvaized committed Feb 5, 2024
1 parent 3767e8e commit 51952d9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.0.4
- optimized code for persistent background script
- minified content script for better page load speed
- don't process window focus events when lost focus

0.0.3
- added context menu entry for popups to open page in main window
- added context menu entry to search for selected text in popup
Expand Down
48 changes: 26 additions & 22 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,35 @@ chrome.runtime.onMessage.addListener(
}
);

const openLinkContextMenuItem = {
"id": "openInPopupWindow",
"title": chrome.i18n.getMessage('openInPopupWindow'),
"contexts": ["link"]
};
chrome.runtime.onInstalled.addListener(function(){
const openLinkContextMenuItem = {
"id": "openInPopupWindow",
"title": chrome.i18n.getMessage('openInPopupWindow'),
"contexts": ["link"]
};

const openInMainWindowContextMenuItem = {
"id": "openInMainWindow",
"title": chrome.i18n.getMessage('openPageInMainWindow'),
"visible": false,
"contexts": ["page"]
}

const searchInPopupWindowContextMenuItem = {
"id": "searchInPopupWindow",
"title": chrome.i18n.getMessage('searchInPopupWindow'),
"contexts": ["selection"]
};

const openInMainWindowContextMenuItem = {
"id": "openInMainWindow",
"title": chrome.i18n.getMessage('openPageInMainWindow'),
"visible": false,
"contexts": ["page"]
}
chrome.contextMenus.create(openLinkContextMenuItem);
chrome.contextMenus.create(openInMainWindowContextMenuItem);
chrome.contextMenus.create(searchInPopupWindowContextMenuItem);
})

const searchInPopupWindowContextMenuItem = {
"id": "searchInPopupWindow",
"title": chrome.i18n.getMessage('searchInPopupWindow'),
"contexts": ["selection"]
};

chrome.windows.onFocusChanged.addListener(
function(w){
if (w < 0) return; /// don't process when window lost focus
chrome.windows.getCurrent(
function(w){
if (w.type == 'popup'){
Expand All @@ -36,8 +44,8 @@ chrome.windows.onFocusChanged.addListener(
chrome.contextMenus.update("openInMainWindow", {"visible": false});
}
},
);
}
);
}
);


Expand All @@ -46,10 +54,6 @@ chrome.storage.onChanged.addListener((changes) => {
});


chrome.contextMenus.create(openLinkContextMenuItem);
chrome.contextMenus.create(openInMainWindowContextMenuItem);
chrome.contextMenus.create(searchInPopupWindowContextMenuItem);

chrome.contextMenus.onClicked.addListener(function(clickData) {
if (clickData.menuItemId == 'openInMainWindow') {
chrome.tabs.create({url: clickData.pageUrl, active:false });
Expand Down
4 changes: 1 addition & 3 deletions content.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Open in Popup window",
"description": "__MSG_extensionDescription__",
"default_locale": "en",
"version": "0.0.3",
"version": "0.0.4",
"icons": {
"48": "icon.svg",
"96": "icon.svg",
Expand Down

0 comments on commit 51952d9

Please sign in to comment.