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

upgrade to Manifest V3 #193

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
WEB_EXT_ID: ${{ secrets.WEB_EXT_ID }}
chrome:
name: Chrome
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions src/browser_action/permissions_banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const permissionsBannerElement = document.getElementById('permissions-banner');
const permissionsButton = document.getElementById('grant-host-permission');
const updatePermissionsBannerVisibility = hasHostPermission => {
permissionsBannerElement.hidden = hasHostPermission;
};
permissionsButton.addEventListener('click', () => {
browser.permissions
.request({ origins: ['*://www.tumblr.com/*'] })
.then(updatePermissionsBannerVisibility);
});
browser.permissions
.contains({ origins: ['*://www.tumblr.com/*'] })
.then(updatePermissionsBannerVisibility);
31 changes: 30 additions & 1 deletion src/browser_action/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ label ~ label {
margin-top: 1ch;
}

button {
main button {
padding: 0;
border: none;
margin: 0;
Expand Down Expand Up @@ -124,3 +124,32 @@ a {
select:not([data-value="custom"]) ~ :is([for="font-family-custom"], [id="font-family-custom"]) {
display: none;
}

#permissions-banner {
box-sizing: border-box;
width: 375px;
min-width: 100%;
max-width: 100%;
padding: 8px 4px;
border-bottom: 1px solid rgb(var(--active-grey));

text-align: center;
}

#grant-host-permission {
display: block;
padding: 0.5ch 1ch;
border-radius: 0.5ch;
margin: 8px auto 0;

font-family: 'Courier New', Courier, monospace;
line-height: 1;
}

#grant-host-permission:focus {
outline: 2px solid rgb(var(--accent));
}

#permissions-banner:not([hidden]) + #embedded-banner {
display: none;
}
5 changes: 5 additions & 0 deletions src/browser_action/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<link rel="stylesheet" href="popup.css">
</head>
<body>
<header id="permissions-banner" hidden>
&#x26A0;&#xFE0F; Palettes for Tumblr needs additional permissions in order to apply palettes automatically.
<button id="grant-host-permission">Always allow on www.tumblr.com</button>
</header>
<main>
<div>
<label for="palette">
Expand Down Expand Up @@ -53,5 +57,6 @@ <h4>Change Palette</h4>
<script src="render_palettes.js"></script>
<script src="render_font_family.js"></script>
<script src="render_font_size.js"></script>
<script src="permissions_banner.js"></script>
</body>
</html>
17 changes: 10 additions & 7 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Palettes for Tumblr",
"version": "1.1.0",

Expand All @@ -10,8 +10,7 @@
"128": "icons/128.png"
},

"browser_action": {
"browser_style": true,
"action": {
"default_icon": {
"16": "icons/16.png",
"48": "icons/48.png",
Expand Down Expand Up @@ -39,15 +38,19 @@
"open_in_tab": true
},
"permissions": [ "storage" ],
"web_accessible_resources": [ "palettes.json", "paletteData.json" ],
"web_accessible_resources": [{
"resources": [ "palettes.json", "paletteData.json" ],
"matches": [ "*://www.tumblr.com/*" ]
}],

"minimum_chrome_version": "38",
"minimum_chrome_version": "88",
"browser_specific_settings": {
"gecko": {
"strict_min_version": "113.0"
"id": "{04b5e1e9-3044-41fd-be51-e8915008ad16}",
"strict_min_version": "120.0"
},
"gecko_android": {
"strict_min_version": "113.0"
"strict_min_version": "120.0"
}
}
}
13 changes: 13 additions & 0 deletions src/options/modules/permissions_banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const permissionsBannerElement = document.getElementById('permissions-banner');
const permissionsButton = document.getElementById('grant-host-permission');
const updatePermissionsBannerVisibility = hasHostPermission => {
permissionsBannerElement.hidden = hasHostPermission;
};
permissionsButton.addEventListener('click', () => {
browser.permissions
.request({ origins: ['*://www.tumblr.com/*'] })
.then(updatePermissionsBannerVisibility);
});
browser.permissions
.contains({ origins: ['*://www.tumblr.com/*'] })
.then(updatePermissionsBannerVisibility);
29 changes: 29 additions & 0 deletions src/options/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,32 @@ input[type="text"]:disabled {
#select-all { grid-column: 1 / 2; }
#select-none { grid-column: 2 / 3; }
#export-list, #save-file { grid-column: 1 / 3; }

#permissions-banner {
box-sizing: border-box;
width: 375px;
min-width: 100%;
max-width: 100%;
padding: 8px 4px;
border-bottom: 1px solid rgb(var(--active-grey));

text-align: center;
}

#grant-host-permission {
display: block;
padding: 0.5ch 1ch;
border-radius: 0.5ch;
margin: 8px auto 0;

font-family: 'Courier New', Courier, monospace;
line-height: 1;
}

#grant-host-permission:focus {
outline: 2px solid rgb(var(--accent));
}

#permissions-banner:not([hidden]) + #embedded-banner {
display: none;
}
4 changes: 4 additions & 0 deletions src/options/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ <h1>Transfer palettes</h1>
</section>
</aside>
<main>
<header id="permissions-banner" hidden>
&#x26A0;&#xFE0F; Palettes for Tumblr needs additional permissions in order to apply palettes automatically.
<button id="grant-host-permission">Always allow on www.tumblr.com</button>
</header>
<form id="palette-form">
<fieldset>
<div>
Expand Down
1 change: 1 addition & 0 deletions src/options/ui.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exportList } from './modules/backup.js';
import { hexToRgb, rgbToHex } from './modules/color.js';
import { getTimestamp } from './modules/datetime.js';
import './modules/permissions_banner.js';

const { getURL } = browser.runtime;
const getBuiltInPaletteList = fetch(getURL('/palettes.json')).then(response => response.json());
Expand Down