mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
feat: kofi + update dompurify function
This commit is contained in:
@@ -32,6 +32,7 @@ import LogoLightOutline from '@/resources/icons/betterseqta-light-outline.png'
|
|||||||
import icon48 from '@/resources/icons/icon-48.png?base64'
|
import icon48 from '@/resources/icons/icon-48.png?base64'
|
||||||
import assessmentsicon from '@/seqta/icons/assessmentsIcon'
|
import assessmentsicon from '@/seqta/icons/assessmentsIcon'
|
||||||
import coursesicon from '@/seqta/icons/coursesIcon'
|
import coursesicon from '@/seqta/icons/coursesIcon'
|
||||||
|
import kofi from '@/resources/kofi.png'
|
||||||
|
|
||||||
// Stylesheets
|
// Stylesheets
|
||||||
import iframeCSS from '@/css/iframe.scss?raw'
|
import iframeCSS from '@/css/iframe.scss?raw'
|
||||||
@@ -337,6 +338,10 @@ export function OpenWhatsNewPopup() {
|
|||||||
`,
|
`,
|
||||||
).firstChild
|
).firstChild
|
||||||
|
|
||||||
|
const kofi_url = browser.runtime.getURL(kofi)
|
||||||
|
|
||||||
|
console.log(kofi_url)
|
||||||
|
|
||||||
let footer = stringToHTML(
|
let footer = stringToHTML(
|
||||||
/* html */ `
|
/* html */ `
|
||||||
<div class="whatsnewFooter">
|
<div class="whatsnewFooter">
|
||||||
@@ -358,6 +363,12 @@ export function OpenWhatsNewPopup() {
|
|||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="https://ko-fi.com/sethburkart" target="_blank" style="background: none !important; margin:0;margin-left:6px; padding:0;">
|
||||||
|
<img height="25" style="border:0px;height:25px;" src="chrome-extension://gkgllhboiibhncnhlijhkbnamfpomjph/resources/kofi.png" border="0" alt="Buy Me a Coffee at ko-fi.com" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`).firstChild
|
`).firstChild
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
@@ -1,12 +1,20 @@
|
|||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
|
||||||
export default function stringToHTML(str: string, styles = false) {
|
export default function stringToHTML(str: string, styles = false) {
|
||||||
var parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
str = DOMPurify.sanitize(str, { ADD_ATTR: ['onclick'] });
|
|
||||||
var doc = parser.parseFromString(str, 'text/html');
|
|
||||||
|
str = DOMPurify.sanitize(str, {
|
||||||
|
ADD_ATTR: ['onclick'],
|
||||||
|
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|chrome-extension):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
||||||
|
});
|
||||||
|
|
||||||
|
const doc = parser.parseFromString(str, 'text/html');
|
||||||
|
|
||||||
if (styles) {
|
if (styles) {
|
||||||
doc.body.style.cssText =
|
doc.body.style.cssText =
|
||||||
'height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);';
|
'height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);';
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc.body;
|
return doc.body;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user