From 3557d884814ac8523042d6416bf606b79078cb95 Mon Sep 17 00:00:00 2001 From: linuxdev Date: Mon, 30 Dec 2024 00:08:10 -0500 Subject: [PATCH 1/6] refactor/fix: env naming schemes --- src/background/index.ts | 4 ++-- src/popup/indexNew.tsx | 2 +- src/popup/indexOld.tsx | 2 +- src/services/Logger.ts | 4 ++-- src/services/TrackEventService.ts | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/background/index.ts b/src/background/index.ts index b3d89d7..57a21bd 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -41,7 +41,7 @@ const openInstallationWelcomePage = async (eventReason: chrome.runtime.OnInstall chrome.tabs.create({ active: true, - url: `https://jiffyreader.com/welcome?browser=${browserTargetName}&event=${eventReason}&version=${envService.VERSION}`, + url: `https://jiffyreader.com/welcome?browser=${browserTargetName}&event=${eventReason}&version=${envService.PLASMO_VERSION}`, }); }; @@ -149,7 +149,7 @@ async function onInstallHandler(event: chrome.runtime.InstalledDetails) { const eventReason = event.reason; - const newVersion = envService.VERSION; + const newVersion = envService.PLASMO_VERSION; const { previousVersion } = event; const isNewVersion = previousVersion !== newVersion; Logger.logInfo({ newVersion, previousVersion, isNewVersion }); diff --git a/src/popup/indexNew.tsx b/src/popup/indexNew.tsx index 6cf48a5..0cedf10 100644 --- a/src/popup/indexNew.tsx +++ b/src/popup/indexNew.tsx @@ -539,7 +539,7 @@ function Footer({ textColor = 'text-secondary', chrome, onClickPasser }) {
-
{envService.VERSION_NAME}
+
{envService.PLASMO_VERSION_NAME}
{/*
*/} @@ -539,7 +537,7 @@ function Footer({ textColor = 'text-secondary', chrome, onClickPasser }) {
-
{envService.PLASMO_VERSION_NAME}
+
Version: {envService.PLASMO_PUBLIC_VERSION_NAME}
{/*
-
{envService.PLASMO_VERSION_NAME}
+
{envService.PLASMO_PUBLIC_VERSION_NAME}
+ +
)} diff --git a/src/popup/indexOld.tsx b/src/popup/indexOld.tsx index 5dedb29..ba25d8f 100644 --- a/src/popup/indexOld.tsx +++ b/src/popup/indexOld.tsx @@ -14,6 +14,7 @@ import defaultPrefs from '~services/preferences'; import runTimeHandler from '~services/runTimeHandler'; import { envService } from '~services/envService'; +import { HtmlNodeToggles } from './HtmlNodeToggles'; import Shortcut, { ShortcutGuide } from './shorcut'; import { ShowDebugInline } from './ShowInlineDebug'; @@ -485,6 +486,8 @@ function IndexPopupOld() { onClick={() => updateConfig('scope', 'reset')}> {chrome.i18n.getMessage('resetBtnText')} + +
)} {!errorOccured && } diff --git a/src/popup/shorcut.tsx b/src/popup/shorcut.tsx index 062ccac..8c749af 100644 --- a/src/popup/shorcut.tsx +++ b/src/popup/shorcut.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'; import Logger from '~services/Logger'; import runTimeHandler from '~services/runTimeHandler'; +import { envService } from '~services/envService'; import { usePopupContext } from './context'; export function useShortcut() { diff --git a/src/popup/useGetTabOriginCb.tsx b/src/popup/useGetTabOriginCb.tsx new file mode 100644 index 0000000..865f3e4 --- /dev/null +++ b/src/popup/useGetTabOriginCb.tsx @@ -0,0 +1,4 @@ +import { useCallback } from 'react'; +import TabHelper from '~services/TabHelper'; + +export const useGetTabOriginCb = () => useCallback(async () => await TabHelper.getTabOrigin(await TabHelper.getActiveTab(true)), [TabHelper]); diff --git a/src/services/documentParser.ts b/src/services/documentParser.ts index 062600d..b9542a1 100644 --- a/src/services/documentParser.ts +++ b/src/services/documentParser.ts @@ -194,18 +194,21 @@ function addStyles(styleText, document) { document.head.appendChild(style); } -const setAttribute = (documentRef) => (attribute, value) => { +const amendClasses = (documentRef: typeof document) => (action: 'add' | 'remove', classList: string[]) => + action === 'add' ? documentRef.body.classList.add(...classList) : document.body.classList.remove(...classList); + +const setAttribute = (documentRef: typeof document) => (attribute, value) => { documentRef.body.setAttribute(attribute, value); }; -const getAttribute = (documentRef) => (attribute) => documentRef.body.getAttribute(attribute); +const getAttribute = (documentRef: typeof document) => (attribute) => documentRef.body.getAttribute(attribute); -const setProperty = (documentRef) => (property, value) => { +const setProperty = (documentRef: typeof document) => (property, value) => { documentRef.body.style.setProperty(property, value); }; -const getProperty = (documentRef) => (property) => documentRef.body.style.getPropertyValue(property); +const getProperty = (documentRef: typeof document) => (property) => documentRef.body.style.getPropertyValue(property); -const setSaccadesStyle = (documentRef) => (style) => { +const setSaccadesStyle = (documentRef: typeof document) => (style) => { Logger.logInfo('saccades-style', style); if (/bold/i.test(style)) { @@ -223,12 +226,13 @@ const setSaccadesStyle = (documentRef) => (style) => { export default { setReadingMode, - makeHandlers: (documentRef) => ({ + makeHandlers: (documentRef: typeof document) => ({ setAttribute: setAttribute(documentRef), getAttribute: getAttribute(documentRef), setProperty: setProperty(documentRef), getProperty: getProperty(documentRef), setSaccadesStyle: setSaccadesStyle(documentRef), + amendClasses: amendClasses(documentRef), }), hasLatex, }; diff --git a/src/services/preferences.ts b/src/services/preferences.ts index c8c1648..3fb95ab 100644 --- a/src/services/preferences.ts +++ b/src/services/preferences.ts @@ -21,6 +21,23 @@ const defaultPrefs = { showBeta: true, transformControlPanelText: false, autoOnDelay: 5_000, + showContentDebugOverlay: false, + symanticTags: { + nav: true, + footer: true, + aside: true, + a: true, + button: true, + p: true, + pre: true, + span: true, + code: true, + caption: true, + li: true, + ul: true, + ol: true, + dialog: true, + }, }; export default defaultPrefs; diff --git a/src/services/usePrefs.tsx b/src/services/usePrefs.tsx index a863345..9100f7f 100644 --- a/src/services/usePrefs.tsx +++ b/src/services/usePrefs.tsx @@ -84,10 +84,17 @@ const usePrefs = (getOrigin: () => Promise, initialize = false, target = })(); }, [getOrigin]); + const updateConfig = (key: T, value: Prefs[T], configLocal = outPrefs, _getTabOriginfn = getOrigin) => { + const newConfig = { ...configLocal, [key]: value }; + + setPrefsExternal(_getTabOriginfn, newConfig.scope, newConfig); + }; + const outPrefs = getActivePrefs(); Logger.logInfo('%cusePrefs.return', 'background-color:lime'); Logger.LogTable({ privateOrigin, outPrefs, prefStore, area }); - return [outPrefs, setPrefsExternal]; + + return [outPrefs, setPrefsExternal, updateConfig]; }; export default usePrefs; diff --git a/src/styles/contentStyle.scss b/src/styles/contentStyle.scss index 646a970..2f5dd65 100644 --- a/src/styles/contentStyle.scss +++ b/src/styles/contentStyle.scss @@ -10,7 +10,13 @@ $hue3: #561f37ff; $hue4: rgb(68, 155, 255); $delta: 8%; -$saccadesColorsBase: (0, $hue1), (1, $hue2), (2, $hue3), (3, $hue4); +$saccadesColorsBase: ( + 0, + $hue1), + (1, $hue2), + (2, $hue3), + (3, $hue4 +); /** generate (3) fixation-strength variants @@ -57,6 +63,7 @@ $saccadesColorsBase: (0, $hue1), (1, $hue2), (2, $hue3), (3, $hue4); } [br-mode='on'] { + br-bold *, br-edge { opacity: (var(--fixation-edge-opacity, $activeFixationOpacity)); @@ -71,4 +78,28 @@ $saccadesColorsBase: (0, $hue1), (1, $hue2), (2, $hue3), (3, $hue4); @include makeColorVariants($color, $id, -$delta, 'dark'); } + + $excludedElements: ( + nav, + footer, + p, + a, + button, + aside + ); + +@each $excludedElement in $excludedElements { + + &.br-exclusions-#{$excludedElement} #{$excludedElement} { + + & br-bold :is(*, [fixation-strength]), + & br-edge { + --fixation-edge-opacity: initial !important; + --br-line-height: initial !important; + --br-boldness: initial !important; + opacity: initial; + } + } + } +} \ No newline at end of file From 8f28bc6d8e14e4d72867ddd5109262994773029b Mon Sep 17 00:00:00 2001 From: linuxdev Date: Mon, 30 Dec 2024 07:57:07 -0500 Subject: [PATCH 5/6] update/ui: fix content debug overlay styling --- src/contents/content.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/contents/content.tsx b/src/contents/content.tsx index f5f9700..081ae59 100644 --- a/src/contents/content.tsx +++ b/src/contents/content.tsx @@ -38,9 +38,10 @@ const OVERLAY_STYLE = { bottom: '40px', left: '40px', display: 'flex', - background: 'white', + background: '#3c2020', padding: '15px', flexDirection: 'column' as 'row', + text: 'light', }; const injectPassiveStyleOverides = (document: Document) => { From 30f59d163a8c371a51adb5d4900a1b5408a90fcc Mon Sep 17 00:00:00 2001 From: gh-action Date: Mon, 30 Dec 2024 13:18:17 +0000 Subject: [PATCH 6/6] chore(release): 1.4.0 --- CHANGELOG.md | 7 ++++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6333bf..0558a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. -## [1.3.7](https://github.com/ansh/jiffyreader.com/compare/v1.3.5...v1.3.7) (2024-12-29) +## [1.4.0](https://github.com/ansh/jiffyreader.com/compare/v1.3.5...v1.4.0) (2024-12-30) + + +### Features + +* ability to enable and disable elements on a page like buttons, links, ... etc ([a97e0ea](https://github.com/ansh/jiffyreader.com/commit/a97e0eade9974c63bb67e079c8ae198f0f64d50d)) ## [1.3.5](https://github.com/ansh/jiffyreader.com/compare/v1.3.4...v1.3.5) (2024-12-29) diff --git a/package-lock.json b/package-lock.json index 2d98869..b4d5991 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jiffy-reader", - "version": "1.3.7", + "version": "1.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jiffy-reader", - "version": "1.3.7", + "version": "1.4.0", "license": "ISC", "dependencies": { "@plasmohq/prettier-plugin-sort-imports": "^1.1.1", diff --git a/package.json b/package.json index 3492ecd..059514d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jiffy-reader", "displayName": "Jiffy reader", - "version": "1.3.7", + "version": "1.4.0", "description": "jiffy reader", "packageManager": "yarn@1.22.19", "scripts": {