4 Commits

Author SHA1 Message Date
f292bd7149 nit: added footer with version and github. 2025-10-08 16:32:04 +03:00
584ced252f ci: publish on version tag push 2025-10-08 16:26:32 +03:00
semantic-release-bot
ff5752da84 chore(release): 1.8.3
## [1.8.3](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.2...v1.8.3) (2025-10-08)

### Bug Fixes

* stop observing when highlightting is disabled ([d7c8dbb](d7c8dbb5f0))
2025-10-08 16:11:52 +03:00
d7c8dbb5f0 fix: stop observing when highlightting is disabled 2025-10-08 16:11:25 +03:00
9 changed files with 124 additions and 21 deletions

View File

@@ -2,7 +2,8 @@ name: Publish Chrome Extension
on: on:
push: push:
branches: [ main ] tags:
- 'v*'
jobs: jobs:
publish: publish:

View File

@@ -1,3 +0,0 @@
{
"kiroAgent.configureMCP": "Enabled"
}

View File

@@ -1,3 +1,10 @@
## [1.8.3](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.2...v1.8.3) (2025-10-08)
### Bug Fixes
* stop observing when highlightting is disabled ([d7c8dbb](https://github.com/obsqrbtz/goose-highlighter/commit/d7c8dbb5f0011afe83739841218aa737794074e3))
## [1.8.2](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.1...v1.8.2) (2025-10-08) ## [1.8.2](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.1...v1.8.2) (2025-10-08)

View File

@@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"name": "__MSG_extension_name__", "name": "__MSG_extension_name__",
"description": "__MSG_extension_description__", "description": "__MSG_extension_description__",
"version": "1.8.2", "version": "1.8.3",
"default_locale": "en", "default_locale": "en",
"permissions": [ "permissions": [
"scripting", "scripting",

View File

@@ -613,3 +613,39 @@ body::-webkit-scrollbar-corner,
.exception-remove:hover { .exception-remove:hover {
background: #d00030; background: #d00030;
} }
/* Footer Styles */
.footer {
margin-top: 16px;
padding: 12px 16px;
border-top: 1px solid var(--input-border);
background: var(--section-bg);
}
.footer-content {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.8em;
color: var(--text-color);
opacity: 0.7;
}
.version {
font-weight: 500;
}
.github-link {
display: flex;
align-items: center;
gap: 4px;
color: var(--text-color);
text-decoration: none;
opacity: 0.7;
transition: opacity 0.2s ease, color 0.2s ease;
}
.github-link:hover {
opacity: 1;
color: var(--accent);
}

View File

@@ -149,6 +149,16 @@
</div> </div>
</div> </div>
<footer class="footer">
<div class="footer-content">
<span class="version">v<span id="version-number">...</span></span>
<a href="https://github.com/obsqrbtz/goose-highlighter" target="_blank" class="github-link">
<i class="fa-brands fa-github"></i>
<span>GitHub</span>
</a>
</div>
</footer>
<script type="module" src="../dist/popup/popup.js"></script> <script type="module" src="../dist/popup/popup.js"></script>
</body> </body>

View File

@@ -12,6 +12,7 @@ export class ContentScript {
private matchCase = false; private matchCase = false;
private matchWhole = false; private matchWhole = false;
private highlightEngine: HighlightEngine; private highlightEngine: HighlightEngine;
private isProcessing = false;
constructor() { constructor() {
this.highlightEngine = new HighlightEngine(() => this.processHighlights()); this.highlightEngine = new HighlightEngine(() => this.processHighlights());
@@ -96,11 +97,19 @@ export class ContentScript {
} }
private processHighlights(): void { private processHighlights(): void {
if (!this.isGlobalHighlightEnabled || this.isCurrentSiteException) { if (this.isProcessing) return;
this.highlightEngine.clearHighlights(); this.isProcessing = true;
return;
}
this.highlightEngine.highlight(this.lists, this.matchCase, this.matchWhole); try {
if (!this.isGlobalHighlightEnabled || this.isCurrentSiteException) {
this.highlightEngine.clearHighlights();
this.highlightEngine.stopObserving();
return;
}
this.highlightEngine.highlight(this.lists, this.matchCase, this.matchWhole);
} finally {
this.isProcessing = false;
}
} }
} }

View File

@@ -7,7 +7,23 @@ export class HighlightEngine {
private observer: MutationObserver; private observer: MutationObserver;
constructor(private onUpdate: () => void) { constructor(private onUpdate: () => void) {
this.observer = new MutationObserver(DOMUtils.debounce(onUpdate, 300)); this.observer = new MutationObserver(DOMUtils.debounce((mutations: MutationRecord[]) => {
const hasRelevantChanges = mutations.some((mutation: MutationRecord) => {
if (mutation.target instanceof Element && mutation.target.hasAttribute('data-gh')) {
return false;
}
const addedNodes = Array.from(mutation.addedNodes);
const removedNodes = Array.from(mutation.removedNodes);
const isOurChange = [...addedNodes, ...removedNodes].some(node =>
node instanceof Element && (node.hasAttribute('data-gh') || node.querySelector('[data-gh]'))
);
return !isOurChange;
});
if (hasRelevantChanges) {
onUpdate();
}
}, 300));
} }
private initializeStyleSheet(): void { private initializeStyleSheet(): void {
@@ -45,14 +61,8 @@ export class HighlightEngine {
} }
clearHighlights(): void { clearHighlights(): void {
const highlightedElements = document.querySelectorAll('[data-gh]'); this.observer.disconnect();
highlightedElements.forEach(element => { this.clearHighlightsInternal();
const parent = element.parentNode;
if (parent) {
parent.replaceChild(document.createTextNode(element.textContent || ''), element);
parent.normalize();
}
});
} }
private getTextNodes(): Text[] { private getTextNodes(): Text[] {
@@ -100,7 +110,8 @@ export class HighlightEngine {
highlight(lists: HighlightList[], matchCase: boolean, matchWhole: boolean): void { highlight(lists: HighlightList[], matchCase: boolean, matchWhole: boolean): void {
this.observer.disconnect(); this.observer.disconnect();
this.clearHighlights();
this.clearHighlightsInternal();
const activeWords = this.extractActiveWords(lists); const activeWords = this.extractActiveWords(lists);
if (activeWords.length === 0) { if (activeWords.length === 0) {
@@ -146,11 +157,34 @@ export class HighlightEngine {
this.startObserving(); this.startObserving();
} }
private clearHighlightsInternal(): void {
const highlightedElements = document.querySelectorAll('[data-gh]');
highlightedElements.forEach(element => {
const parent = element.parentNode;
if (parent) {
parent.replaceChild(document.createTextNode(element.textContent || ''), element);
parent.normalize();
}
});
if (this.styleSheet && this.styleSheet.cssRules.length > 0) {
while (this.styleSheet.cssRules.length > 0) {
this.styleSheet.deleteRule(0);
}
}
}
stopObserving(): void {
this.observer.disconnect();
}
private startObserving(): void { private startObserving(): void {
this.observer.observe(document.body, { this.observer.observe(document.body, {
childList: true, childList: true,
subtree: true, subtree: true,
characterData: true characterData: true,
// Don't observe attribute changes to avoid triggering on our own style changes
attributes: false
}); });
} }

View File

@@ -15,8 +15,17 @@ function localizePage(): void {
}); });
} }
function displayVersion(): void {
const manifest = chrome.runtime.getManifest();
const versionElement = document.getElementById('version-number');
if (versionElement && manifest.version) {
versionElement.textContent = manifest.version;
}
}
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
localizePage(); localizePage();
displayVersion();
const controller = new PopupController(); const controller = new PopupController();
await controller.initialize(); await controller.initialize();
}); });