Skip to content

Commit 6eb554a

Browse files
author
huangbaoshan
committed
fix: some bug
1 parent b27851f commit 6eb554a

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed
18.1 KB
Binary file not shown.

manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
],
2929
"homepage_url": "https://github.com/febaoshan/edge-extensions-github-code-viewer",
3030
"permissions": [
31-
"contextMenus",
32-
"declarativeContent"
31+
"contextMenus"
3332
],
3433
"background": {
3534
"scripts": ["src/background.js"]

src/background.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
chrome.contextMenus.create({
2-
title: 'open with github-code-viewer',
3-
contexts: ['page'],
4-
onclick: function (params) {
5-
const { pageUrl } = params;
6-
console.log('pageUrl: ', pageUrl);
7-
chrome.tabs.create({ url: pageUrl.replace(/github.com/, 'github1s.com') });
8-
},
9-
documentUrlPatterns: ['https://*.github.com/*/*']
10-
});
11-
12-
chrome.runtime.onInstalled.addListener(function () {
13-
chrome.declarativeContent.onPageChanged.removeRules(undefined, function () {
14-
chrome.declarativeContent.onPageChanged.addRules([
15-
{
16-
conditions: [
17-
new chrome.declarativeContent.PageStateMatcher({ pageUrl: { urlContains: 'github.com' } })
18-
],
19-
actions: [new chrome.declarativeContent.ShowPageAction()]
20-
}
21-
]);
1+
if (chrome && chrome.contextMenus) {
2+
chrome.contextMenus.create({
3+
title: 'open with github-code-viewer',
4+
contexts: ['page'],
5+
onclick: function (params) {
6+
const { pageUrl = '' } = params;
7+
8+
chrome.tabs.create({ url: pageUrl.replace(/github.com/, 'github1s.com') });
9+
},
10+
documentUrlPatterns: ['https://*.github.com/*/*']
2211
});
23-
});
12+
}

0 commit comments

Comments
 (0)