Skip to content

Commit

Permalink
- migrate to manifest_version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
howanghk committed Jul 28, 2022
1 parent afe65c7 commit 57ab98c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 howang <howanghk at gmail dot com>
Copyright (c) 2015-2022 howanghk

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Refresh Active Frame
====================
This extension let you refresh a frame with keyborad shoutcut (Cmd+Ctrl+R on Mac, Alt+Shift+R otherwise), if no frame is active it will fallback to refresh the whole page.
This extension let you refresh a frame with keyboard shortcut (Cmd+Ctrl+R on Mac, Alt+Shift+R otherwise), if no frame is active it will fallback to refresh the whole page.

Install
-------
[![available in the chrome web store](https://developer.chrome.com/webstore/images/ChromeWebStore_BadgeWBorder_v2_206x58.png)](https://chrome.google.com/webstore/detail/refresh-active-frame/imcfppeifknphfhaibbbidhnjecmfohi)
[![available in the chrome web store](https://storage.googleapis.com/web-dev-uploads/image/WlD8wC6g8khYWPJUsQceQkhXSlv1/UV4C4ybeBTsZt43U4xis.png)](https://chrome.google.com/webstore/detail/refresh-active-frame/imcfppeifknphfhaibbbidhnjecmfohi)

Manual Install
--------------
Expand All @@ -17,7 +17,7 @@ Manual Install

License
-------
Copyright (c) 2015 howang &lt;howanghk at gmail dot com&gt;
Copyright (c) 2015-2022 howanghk

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
29 changes: 29 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

// ref: https://developer.chrome.com/docs/extensions/reference/tabs/#get-the-current-tab
async function getCurrentTab() {
let queryOptions = { active: true, lastFocusedWindow: true };
// `tab` will either be a `tabs.Tab` instance or `undefined`.
let [tab] = await chrome.tabs.query(queryOptions);
return tab;
}

function refreshActiveFrameInTab(tab) {
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ['refresh_active_frame.js']
});
}

chrome.action.onClicked.addListener((tab) => {
refreshActiveFrameInTab(tab);
});

chrome.commands.onCommand.addListener(async (cmd) => {
if (cmd == 'refresh-active-frame') {
let tab = await getCurrentTab();
if (!tab) {
return;
}
refreshActiveFrameInTab(tab);
}
});
17 changes: 0 additions & 17 deletions eventPage.js

This file was deleted.

14 changes: 7 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"manifest_version": 2,
"manifest_version": 3,

"name": "Refresh Active Frame",
"description": "This extension let you refresh a frame with keyborad shoutcut (Cmd+Ctrl+R on Mac, Alt+Shift+R otherwise), if no frame is active it will fallback to refresh the whole page",
"version": "1.0",
"description": "Refresh active frame or ifrmae with keyboard shortcut, fallback to refresh page if active element is not a frame",
"version": "1.1",
"icons": {
"128": "icon-128.png"
},
"author": "howang",
"homepage_url": "https://www.howang.hk/",

"background": {
"scripts": ["eventPage.js"],
"persistent": false
"service_worker": "background.js"
},

"browser_action": {
"action": {
"default_icon": "icon-19.png",
"default_title": "Refresh Active Frame"
},
Expand All @@ -31,6 +30,7 @@
},

"permissions": [
"activeTab"
"activeTab",
"scripting"
]
}

0 comments on commit 57ab98c

Please sign in to comment.