Skip to content

Commit 2263767

Browse files
authored
Merge pull request #9 from Mimieam/code-refactor
Fixed - deprecated native css import
2 parents afaeaac + d3a7a4c commit 2263767

6 files changed

+40
-17
lines changed

assets/screenshot-1280x800-v0.4.2.png

171 KB
Loading

content/content.ui.mjs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
import { elapsedTime, msToTime, trimTimeString } from '../shared/utils.js';
4+
// import cssModule from './content.ui.module.css';
45

56
export function createElement(tag, attributes = {}, classes = []) {
67
const element = document.createElement(tag);
@@ -13,7 +14,17 @@ export function createElement(tag, attributes = {}, classes = []) {
1314

1415
export async function setupUI(divId = 'ui', tabStats) {
1516

16-
const cssModule = await import('./content.ui.module.css', {assert: {type: 'css'}});
17+
// const cssModule = await import('./content.ui.module.css', {assert: {type: 'css'}}); // this is now deprecated...
18+
const cssModule = await import('./content.ui.module.css', {with: {type: 'css'}});
19+
20+
const sheet = new CSSStyleSheet();
21+
await sheet.replace('@import url("myStyle.css")')
22+
// .then(sheet => {
23+
// console.log('Styles loaded successfully');
24+
// })
25+
// .catch(err => {
26+
// console.error('Failed to load:', err);
27+
// });
1728

1829
const ui = createElement("div", {}, ["tabStats"])
1930
const header = createElement("div", {}, ["header"])
@@ -25,6 +36,7 @@ export async function setupUI(divId = 'ui', tabStats) {
2536
host.attachShadow({mode: 'open'});
2637
document.body.appendChild(host)
2738
host.shadowRoot.adoptedStyleSheets = [cssModule.default]
39+
// host.shadowRoot.adoptedStyleSheets = [sheet]
2840

2941
ui.id = divId
3042

content/loader.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const event = () => {
66

77
const blueishGray = '#9ba6d1'
88
const kindaNicePink = '#fb8990'
9+
const blueishGreen = '#9dd5c1'
10+
11+
912

1013
const logStyle = [
1114
`background: ${blueishGray}`,

content/tracking.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const INTERACTIVE_EVENTS = [
1717
const PAGE_EVENTS = [
1818
'beforeunload', 'pagehide', 'pageshow',
1919
'focus', 'blur', 'visibilitychange', 'resume',
20-
'load', 'unload', 'DOMContentLoaded', 'onreadystatechange'
20+
'load',
21+
// 'unload',
22+
'DOMContentLoaded', 'onreadystatechange'
2123
]
2224

2325
// ⇝⇒֎⊛

manifest.json

+6
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,11 @@
5555
],
5656
"content_security_policy": {
5757
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
58+
},
59+
"browser_specific_settings": {
60+
"gecko": {
61+
"id": "{f9cc6cde-1668-453b-a746-75fb3fde4771}",
62+
"strict_min_version": "42.0"
63+
}
5864
}
5965
}

updateMe.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
This should be a tiny npm package :)
33
updateMe
44
- will update any json file that have a version property .. or not :D
5-
5+
66
2 ways use masking - can increment arbitr
77
node updateMe.js ./manifestmv3.json --x x.x.+3
88
99
simple verbose - only increment by one
10-
node updateMe.js ./manifestmv3.json --bump major
10+
node updateMe.js ./manifestmv3.json --bump major
1111
node updateMe.js ./manifestmv3.json --bump minor
1212
node updateMe.js ./manifestmv3.json --bump patch
1313
14-
lazy way - increment by one with a rolling increment - not hooked
15-
node updateMe.js ./manifestmv3.json
14+
lazy way - increment by one with a rolling increment - not hooked
15+
node updateMe.js ./manifestmv3.json
1616
*/
1717

1818
const fs = require('fs')
1919
function updateVersion(fileName, default_inc = 1, minor_rollover = 10, patch_rollover = 10) {
2020
// Read the manifest file
2121
const manifest = require(fileName);
22-
22+
2323

2424
let version = manifest.version;
2525
if (!version){
@@ -60,11 +60,11 @@ function updateVersionWithMask(fileName, mask){
6060
}
6161
const newVersion = maskVersion(version, mask)
6262
console.log(`Updating ${fileName}: ${manifest.version} => ${newVersion}`)
63-
63+
6464
if (Number.isNaN(newVersion)){
6565
throw new Error (`Could NOT update version of ${fileName} to ${newVersion}`)
6666
}
67-
67+
6868
manifest.version = newVersion;
6969
const manifest_JSON = JSON.stringify(manifest, null, 2);
7070
fs.writeFileSync(fileName, manifest_JSON, { encoding: 'utf8', flag: 'w' });
@@ -106,23 +106,23 @@ try {
106106
let minor_rollover = 10;
107107
let patch_rollover = 10;
108108
let mask = null
109-
109+
110110
let [filename, subcmd, subcmd_arg, ...rest] = args;
111111
// console.log({filename, subcmd, subcmd_arg, rest})
112-
112+
113113
if (!filename) {
114114
throw new Error('Please provide a filename. \n\tEx: updateMe.js [filename] --x [versionMask]');
115115
}
116-
116+
117117
if (subcmd === '--x') {
118118
console.log("Usage: node updateMe.js [filename] --x [versionMask]");
119119
if (!subcmd_arg || (subcmd_arg.length < 5)){
120120
throw new Error("Invalid versionMask, expects x.x.x syntax")
121121
}
122-
return updateVersionWithMask(filename, subcmd_arg)
123-
122+
return updateVersionWithMask(filename, subcmd_arg) // js... returning outside a fn... and it's fine???
123+
124124
} else if (subcmd === '--bump') {
125-
125+
126126
if (!["major", "minor", "patch"].includes(subcmd_arg)){
127127
console.log("Usage: node updateMe.js [filename] --bump <major|minor|patch>")
128128
throw new Error("Invalid bump argument...")
@@ -134,9 +134,9 @@ try {
134134
}
135135
return updateVersionWithMask(filename, mask)
136136
} else {
137-
throw new Error("Please use a valid option: \n\tnode updateMe.js [filename] --x [versionMask] \n\tnode updateMe.js [filename] --bump <major|minor|patch>");
137+
throw new Error("Please use a valid option: \n\tnode updateMe.js [filename] --x [versionMask] \n\tnode updateMe.js [filename] --bump <major|minor|patch>");
138138
}
139-
139+
140140
} catch (error) {
141141
console.error(`Error: ${error.message}`, error);
142142
process.exit(1);

0 commit comments

Comments
 (0)