Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest v3 #219

Merged
merged 6 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extension/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
/app/inpage/build/
/app/inpage/js/
!/app/inpage/output/injected_document_start.js
/app/manifest.json
2 changes: 1 addition & 1 deletion extension/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN npm run vendor

WORKDIR /extension
RUN npm run inpage
RUN npm run build
RUN npm run build-firefox
RUN npm run test

WORKDIR /extension/app
Expand Down
19 changes: 19 additions & 0 deletions extension/app/html3/addressBookV3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html style = 'background-color: var(--bg-color); overflow-y: inherit;'>
<head>
<title>Address Book - The Interceptor</title>
<meta charset = 'utf-8'>
<link rel = 'icon' type = 'image/x-icon' href = 'favicon.ico'>
</head>
<body style = 'background-color: var(--bg-color); margin: auto;'>
<meta name = 'viewport' content = 'width = device-width, initial-scale = 1' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma-divider.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/interceptor.css' />

<main>Loading...</main>

<script src = '../vendor/webextension-polyfill/browser-polyfill.js'></script>
<script type = 'module' src = '../js/addressBookRender.js'></script>
</body>
</html>
19 changes: 19 additions & 0 deletions extension/app/html3/changeChainV3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html style = 'background-color: var(--bg-color);overflow-y: inherit;'>
<head>
<title>Change Chain - The Interceptor</title>
<meta charset = 'utf-8'>
<link rel = 'icon' type = 'image/x-icon' href = 'favicon.ico'>
</head>
<body style = 'background-color: var(--bg-color); margin: auto;'>
<meta name = 'viewport' content = 'width = device-width, initial-scale = 1' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma-divider.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/interceptor.css' />

<main>Loading...</main>

<script src = '../vendor/webextension-polyfill/browser-polyfill.js'></script>
<script type = 'module' src = '../js/changeChain.js'></script>
</body>
</html>
20 changes: 20 additions & 0 deletions extension/app/html3/confirmTransactionV3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html style="background-color:var(--bg-color); overflow-y: inherit;">
<head>
<title>Confirm Transaction - The Interceptor</title>
<meta charset='utf-8'>
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body style = 'background-color: var(--bg-color); margin: auto;'>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="../css/bulma.css" />
<link rel="stylesheet" type="text/css" href="../css/bulma-divider.css" />
<link rel="stylesheet" type="text/css" href="../css/interceptor.css" />
<script src='../vendor/webextension-polyfill/browser-polyfill.js'></script>

<main>Loading...</main>

<!-- a workaround for bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1803984 -->
<script type = 'module' src = '../js/confirmTransaction.js'></script>
</body>
</html>
Binary file added extension/app/html3/favicon.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions extension/app/html3/interceptorAccessV3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html style = 'background-color: var(--bg-color); overflow-y: inherit;'>
<head>
<title>Access Request - The Interceptor</title>
<meta charset = 'utf-8'>
<link rel = 'icon' type = 'image/x-icon' href = 'favicon.ico'>
</head>
<body style = 'background-color: var(--bg-color); margin: auto;'>
<meta name = 'viewport' content = 'width = device-width, initial-scale = 1' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma-divider.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/interceptor.css' />

<main>Loading...</main>

<script src = '../vendor/webextension-polyfill/browser-polyfill.js'></script>
<script type = 'module' src = '../js/interceptorAccess.js'></script>
</body>
</html>
19 changes: 19 additions & 0 deletions extension/app/html3/personalSignV3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html style="background-color:var(--bg-color); overflow-y: inherit;">
<head>
<title>Personal Sign - The Interceptor</title>
<meta charset='utf-8'>
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body style = 'background-color: var(--bg-color); margin: auto;'>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="../css/bulma.css" />
<link rel="stylesheet" type="text/css" href="../css/bulma-divider.css" />
<link rel="stylesheet" type="text/css" href="../css/interceptor.css" />

<main>Loading...</main>

<script src = '../vendor/webextension-polyfill/browser-polyfill.js'></script>
<script type = 'module' src = '../js/personalSign.js'></script>
</body>
</html>
20 changes: 20 additions & 0 deletions extension/app/html3/popupV3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html style = 'background-color: var(--bg-color); width: 520px; height: 600px; min-width: 520px; overflow-y: inherit;'>
<head>
<title>The Interceptor</title>
<meta charset = 'utf-8'>
<link rel = 'icon' type = 'image/x-icon' href = 'favicon.ico'>
</head>
<body style = 'width: 520px; height: 600px; background-color: var(--bg-color); min-width: 520px; margin: auto;'>
<meta name = 'viewport' content = 'width = device-width, initial-scale = 1' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma-divider.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/bulma-badge.css' />
<link rel = 'stylesheet' type = 'text/css' href = '../css/interceptor.css' />

<main>Loading...</main>

<script src = '../vendor/webextension-polyfill/browser-polyfill.js'></script>
<script type = 'module' src = '../js/popup.js'></script>
</body>
</html>
4 changes: 2 additions & 2 deletions extension/app/inpage/output/injected_document_start.js

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

4 changes: 2 additions & 2 deletions extension/app/inpage/ts/document_start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function listenInContentScript() {
let connected = true

// forward all message events to the background script, which will then filter and process them
window.addEventListener('message', messageEvent => {
globalThis.addEventListener('message', messageEvent => {
try {
// we only want the data element, if it exists, and postMessage will fail if it can't clone the object fully (and it cannot clone a MessageEvent)
if (!('data' in messageEvent)) return
Expand All @@ -28,7 +28,7 @@ function listenInContentScript() {
// forward all messages we get from the background script to the window so the page script can filter and process them
extensionPort.onMessage.addListener(response => {
try {
if (connected) window.postMessage(response, '*')
if (connected) globalThis.postMessage(response, '*')
} catch (error) {
console.error(error)
}
Expand Down
File renamed without changes.
40 changes: 40 additions & 0 deletions extension/app/manifestV3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "Interceptor",
"description": "Interceptor",
"version": "0.0.0",
"manifest_version": 3,
"action": {
"default_icon": {
"128": "img/head-not-active.png"
},
"default_title": "The Interceptor"
},
"background": {
"service_worker": "./js/backgroundServiceWorker.js",
"type": "module"
},
"icons": {
"128": "img/head.png",
"400": "img/LOGOA_400x400.png"
},
"permissions": [
"activeTab",
"storage",
"webNavigation",
"scripting"
],
"web_accessible_resources": [
{
"resources": ["vendor/*", "js/*", "inpage/*"],
"matches": ["<all_urls>"] // not sure if this is right?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is valid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be much better if we did activeTab instead, but that requires users to click the extension icon to activate it. This permission requires that we get "read and write access to all websites you visit".

}
],
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"host_permissions": [
"file://*/*",
"http://*/*",
"https://*/*"
]
}
8 changes: 4 additions & 4 deletions extension/app/ts/AddressBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ export function AddressBook() {
changeFilter(activeFilter)
browser.runtime.onMessage.addListener(popupMessageListener)
const scrollListener = () => update()
window.addEventListener('scroll', scrollListener)
globalThis.addEventListener('scroll', scrollListener)

return () => {
browser.runtime.onMessage.removeListener(popupMessageListener)
window.removeEventListener('scroll', scrollListener)
globalThis.removeEventListener('scroll', scrollListener)
}
}, [])

Expand All @@ -258,7 +258,7 @@ export function AddressBook() {
setAddressBookState((previousState) => {
if (previousState === undefined) return previousState
const pageSizePx = PAGE_SIZE * (ELEMENT_SIZE_PX[previousState.activeFilter] + ELEMENT_PADDING_PX)
const newPage = Math.min(Math.floor(window.scrollY / pageSizePx + 0.5), previousState.maxPages)
const newPage = Math.min(Math.floor(globalThis.scrollY / pageSizePx + 0.5), previousState.maxPages)
if (currentPageRef.current === newPage) return previousState

setCurrentPage(newPage)
Expand Down Expand Up @@ -330,7 +330,7 @@ export function AddressBook() {
}

function getWindowSizeInPages(filter: ActiveFilter) {
return Math.ceil(window.innerHeight / getPageSizeInPixels(filter) )
return Math.ceil(globalThis.innerHeight / getPageSizeInPixels(filter) )
}

function openNewAddress(filter: ActiveFilter) {
Expand Down
Loading