mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
fix: iframe theming
This commit is contained in:
+2
-2
@@ -15,10 +15,10 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@parcel/config-webextension": "^2.10.3",
|
"@parcel/config-webextension": "^2.11.0",
|
||||||
"@parcel/optimizer-data-url": "^2.11.0",
|
"@parcel/optimizer-data-url": "^2.11.0",
|
||||||
"@parcel/transformer-inline-string": "^2.11.0",
|
"@parcel/transformer-inline-string": "^2.11.0",
|
||||||
"@parcel/transformer-sass": "^2.11.0",
|
"@parcel/transformer-sass": "2.11.0",
|
||||||
"assert": "^2.0.0",
|
"assert": "^2.0.0",
|
||||||
"browserify-zlib": "^0.2.0",
|
"browserify-zlib": "^0.2.0",
|
||||||
"crypto-browserify": "^3.12.0",
|
"crypto-browserify": "^3.12.0",
|
||||||
|
|||||||
+8
-12
@@ -24,10 +24,10 @@ import browser from 'webextension-polyfill'
|
|||||||
import coursesicon from './seqta/icons/coursesIcon'
|
import coursesicon from './seqta/icons/coursesIcon'
|
||||||
import { delay } from "./seqta/utils/delay"
|
import { delay } from "./seqta/utils/delay"
|
||||||
import { enableCurrentTheme } from './seqta/ui/Themes'
|
import { enableCurrentTheme } from './seqta/ui/Themes'
|
||||||
import iframeCSS from "url:./css/iframe.scss"
|
import iframeCSS from "bundle-text:./css/iframe.scss"
|
||||||
import { onError } from './seqta/utils/onError'
|
import { onError } from './seqta/utils/onError'
|
||||||
import stringToHTML from './seqta/utils/stringToHTML'
|
import stringToHTML from './seqta/utils/stringToHTML'
|
||||||
import { updateAllColors } from './seqta/ui/colors/Manager'
|
import { getDarkMode, updateAllColors } from './seqta/ui/colors/Manager'
|
||||||
import { updateBgDurations } from './seqta/ui/Animation'
|
import { updateBgDurations } from './seqta/ui/Animation'
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@@ -413,6 +413,7 @@ function removeThemeTagsFromNotices () {
|
|||||||
async function updateIframesWithDarkMode(): Promise<void> {
|
async function updateIframesWithDarkMode(): Promise<void> {
|
||||||
// Load the CSS file to overwrite iFrame default CSS
|
// Load the CSS file to overwrite iFrame default CSS
|
||||||
const cssLink = document.createElement('style')
|
const cssLink = document.createElement('style')
|
||||||
|
cssLink.classList.add('iframecss')
|
||||||
const cssContent = document.createTextNode(iframeCSS)
|
const cssContent = document.createTextNode(iframeCSS)
|
||||||
cssLink.appendChild(cssContent)
|
cssLink.appendChild(cssContent)
|
||||||
|
|
||||||
@@ -423,16 +424,14 @@ async function updateIframesWithDarkMode(): Promise<void> {
|
|||||||
const iframe = node as HTMLIFrameElement
|
const iframe = node as HTMLIFrameElement
|
||||||
try {
|
try {
|
||||||
const settings = await browser.storage.local.get('DarkMode') as SettingsState
|
const settings = await browser.storage.local.get('DarkMode') as SettingsState
|
||||||
if (settings.DarkMode) {
|
applyDarkModeToIframe(iframe, cssLink, settings.DarkMode);
|
||||||
applyDarkModeToIframe(iframe, cssLink)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error applying dark mode:', error)
|
console.error('Error applying dark mode:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
if (document.body) {
|
if (document.body) {
|
||||||
observer.observe(document.body, {
|
observer.observe(document.body, {
|
||||||
@@ -449,17 +448,14 @@ async function updateIframesWithDarkMode(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyDarkModeToIframe(iframe: HTMLIFrameElement, cssLink: HTMLStyleElement): void {
|
function applyDarkModeToIframe(iframe: HTMLIFrameElement, cssLink: HTMLStyleElement, DarkMode: boolean): void {
|
||||||
const iframeDocument = iframe.contentDocument
|
const iframeDocument = iframe.contentDocument
|
||||||
if (!iframeDocument) return
|
if (!iframeDocument) return
|
||||||
|
|
||||||
const body = iframeDocument.body
|
if (DarkMode) iframeDocument.body.classList.add('dark')
|
||||||
if (body && body.style.color !== 'white') {
|
|
||||||
body.style.color = 'white'
|
|
||||||
}
|
|
||||||
|
|
||||||
const head = iframeDocument.head
|
const head = iframeDocument.head
|
||||||
if (head && !head.innerHTML.includes('iframe.css')) {
|
if (head && !head.innerHTML.includes('iframecss')) {
|
||||||
head.appendChild(cssLink)
|
head.appendChild(cssLink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-12
@@ -15,7 +15,14 @@
|
|||||||
* along with EvenBetterSEQTA. If not, see <https://www.gnu.org/licenses/>.
|
* along with EvenBetterSEQTA. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
html, p, div, span {
|
body {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
p,
|
||||||
|
div,
|
||||||
|
span {
|
||||||
color: white !important;
|
color: white !important;
|
||||||
text-shadow: 1px 1px 2px #161616, 0 0 1em #161616;
|
text-shadow: 1px 1px 2px #161616, 0 0 1em #161616;
|
||||||
}
|
}
|
||||||
@@ -27,17 +34,26 @@ body {
|
|||||||
blockquote.forward > .preamble {
|
blockquote.forward > .preamble {
|
||||||
color: rgba(255, 255, 255, 0.7) !important;
|
color: rgba(255, 255, 255, 0.7) !important;
|
||||||
|
|
||||||
> .date > .value, blockquote.forward > .preamble > .sender > .value {
|
> p,
|
||||||
|
div,
|
||||||
|
span {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .date > .value,
|
||||||
|
blockquote.forward > .preamble > .sender > .value {
|
||||||
color: rgba(255, 255, 255, 0.7) !important;
|
color: rgba(255, 255, 255, 0.7) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .date > .label, blockquote.forward > .preamble > .sender > .label {
|
> .date > .label,
|
||||||
|
blockquote.forward > .preamble > .sender > .label {
|
||||||
color: rgba(255, 255, 255, 0.7) !important;
|
color: rgba(255, 255, 255, 0.7) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[bgcolor="#ffffff"] {
|
[bgcolor="#ffffff"] > * {
|
||||||
color: black;
|
color: black !important;
|
||||||
|
text-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
table th {
|
table th {
|
||||||
@@ -71,13 +87,6 @@ table th {
|
|||||||
border-top-right-radius: 1rem;
|
border-top-right-radius: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
html, p, div, span {
|
|
||||||
color: white !important;
|
|
||||||
background-color: #232323
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
background-color: #232323;
|
|
||||||
}
|
|
||||||
blockquote.forward > .preamble {
|
blockquote.forward > .preamble {
|
||||||
color: rgba(255, 255, 255, 0.7) !important;
|
color: rgba(255, 255, 255, 0.7) !important;
|
||||||
}
|
}
|
||||||
@@ -101,3 +110,4 @@ blockquote.forward > .preamble > .sender > .label {
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
transition: text-shadow 0.5s;
|
transition: text-shadow 0.5s;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
import './iframe.scss';
|
|
||||||
@@ -6,7 +6,6 @@ import { SettingsState } from '../../../types/storage';
|
|||||||
|
|
||||||
import darkLogo from 'url:../../../resources/icons/betterseqta-light-full.png';
|
import darkLogo from 'url:../../../resources/icons/betterseqta-light-full.png';
|
||||||
import lightLogo from 'url:../../../resources/icons/betterseqta-dark-full.png';
|
import lightLogo from 'url:../../../resources/icons/betterseqta-dark-full.png';
|
||||||
import iFrameCSS from 'url:../../../css/iframe.scss';
|
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
const setCSSVar = (varName: any, value: any) => document.documentElement.style.setProperty(varName, value);
|
const setCSSVar = (varName: any, value: any) => document.documentElement.style.setProperty(varName, value);
|
||||||
@@ -71,7 +70,6 @@ export function updateAllColors(storedSetting: any, newColor = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let alliframes = document.getElementsByTagName('iframe');
|
let alliframes = document.getElementsByTagName('iframe');
|
||||||
let fileref = iFrameCSS;
|
|
||||||
|
|
||||||
for (let i = 0; i < alliframes.length; i++) {
|
for (let i = 0; i < alliframes.length; i++) {
|
||||||
const element = alliframes[i];
|
const element = alliframes[i];
|
||||||
@@ -80,11 +78,11 @@ export function updateAllColors(storedSetting: any, newColor = null) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
(element.contentDocument!.documentElement.childNodes[1] as HTMLIFrameElement).style.color =
|
if (DarkMode) {
|
||||||
DarkMode ? 'white' : 'black';
|
element.contentDocument?.body.classList.add('dark');
|
||||||
element.contentDocument!.documentElement.firstChild!.appendChild(
|
} else {
|
||||||
fileref,
|
element.contentDocument?.body.classList.remove('dark');
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user