Skip to content

Commit

Permalink
use GM_addElement to bypass CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
Vap0r1ze committed Feb 1, 2023
1 parent d2dfd5e commit 1b0b267
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"namespace": "https://github.com/Vap0r1ze/",
"author": "Vap0r1ze",
"description": "nasin sona: o alasa e nimi",
"match": "*://*/*"
"match": "*://*/*",
"grant": [ "GM_addElement" ]
},
"scripts": {
"build": "tsx scripts/build/build.ts",
Expand Down
9 changes: 4 additions & 5 deletions src/display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export function clearWord() {
}

function WordDisplay(word: Word) {
const image = <div class="image" />
GM_addElement(image, "img", { src: `https://sitelen.nimi.li/img/64/${word.word}.png` })

return (
<div class="word">
<div class="info">
Expand All @@ -45,11 +48,7 @@ function WordDisplay(word: Word) {
</div>
<div class="desc">{word.def}</div>
</div>
{word.sitelen_pona && (
<div class="image">
<img src={`https://sitelen.nimi.li/img/64/${word.word}.png`}> </img>
</div>
)}
{word.sitelen_pona && image}
</div>
)
}
Expand Down
10 changes: 3 additions & 7 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
declare module "*.css" {
const source: string
export default source
declare global {
export function GM_addElement(parent: HTMLElement, tag: string, attributes: Record<string, string>): void
}

declare module "~words" {
const words: Record<string, import("./types").Word>
export default words
}
export {}
9 changes: 9 additions & 0 deletions src/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module "*.css" {
const source: string
export default source
}

declare module "~words" {
const words: Record<string, import("./types").Word>
export default words
}

0 comments on commit 1b0b267

Please sign in to comment.