4 Commits
dev ... v1.7.1

Author SHA1 Message Date
semantic-release-bot
1ef21d0975 chore(release): 1.7.1 [skip ci]
## [1.7.1](https://github.com/obsqrbtz/goose-highlighter/compare/v1.7.0...v1.7.1) (2025-06-27)

### Bug Fixes

* unicode support in regex ([ae1cf48](ae1cf48c53))
2025-06-27 14:05:56 +03:00
ae1cf48c53 fix: unicode support in regex 2025-06-27 14:05:12 +03:00
bca37e690f Trigger Build 2025-06-27 00:51:41 +03:00
semantic-release-bot
50c3facfae chore(release): 1.7.0 [skip ci]
# [1.7.0](https://github.com/obsqrbtz/goose-highlighter/compare/v1.6.0...v1.7.0) (2025-06-26)

### Bug Fixes

* colorbox styling ([1e704b5](1e704b51a8))
* colorbox styling ([08ad7c4](08ad7c4325))
* moved import/export to options section ([fe15965](fe15965e89))
* wordlist scrollbar styling ([b30fac5](b30fac5ded))

### Features

* add word search ([80d4bff](80d4bff0b4))
* added matching flags ([759307f](759307f983))
2025-06-27 00:49:54 +03:00
3 changed files with 43 additions and 11 deletions

View File

@@ -1,3 +1,26 @@
## [1.7.1](https://github.com/obsqrbtz/goose-highlighter/compare/v1.7.0...v1.7.1) (2025-06-27)
### Bug Fixes
* unicode support in regex ([ae1cf48](https://github.com/obsqrbtz/goose-highlighter/commit/ae1cf48c53cd42e65279cf2acde1a2860d8a31ee))
# [1.7.0](https://github.com/obsqrbtz/goose-highlighter/compare/v1.6.0...v1.7.0) (2025-06-26)
### Bug Fixes
* colorbox styling ([1e704b5](https://github.com/obsqrbtz/goose-highlighter/commit/1e704b51a859845e539224aeb389a4e493d64520))
* colorbox styling ([08ad7c4](https://github.com/obsqrbtz/goose-highlighter/commit/08ad7c432541ea4240dec05a340ad0b3279ce82f))
* moved import/export to options section ([fe15965](https://github.com/obsqrbtz/goose-highlighter/commit/fe15965e89e8483f6b96eb779617053664c9d5b1))
* wordlist scrollbar styling ([b30fac5](https://github.com/obsqrbtz/goose-highlighter/commit/b30fac5deda7941035d8ae23001c998c2584c03e))
### Features
* add word search ([80d4bff](https://github.com/obsqrbtz/goose-highlighter/commit/80d4bff0b4ef7c9e97506d1fe43a827bcc4b28fd))
* added matching flags ([759307f](https://github.com/obsqrbtz/goose-highlighter/commit/759307f9834a2bbb23e963e2042b7d41d5cfda44))
# [1.6.0](https://github.com/obsqrbtz/goose-highlighter/compare/v1.5.0...v1.6.0) (2025-06-25) # [1.6.0](https://github.com/obsqrbtz/goose-highlighter/compare/v1.5.0...v1.6.0) (2025-06-25)

25
main.js
View File

@@ -62,26 +62,35 @@ function processNodes() {
if (activeWords.length > 0) { if (activeWords.length > 0) {
const wordMap = new Map(); const wordMap = new Map();
for (const word of activeWords) wordMap.set(word.text.toLowerCase(), word); for (const word of activeWords) {
wordMap.set(matchCase ? word.text : word.text.toLowerCase(), word);
let flags = matchCase ? 'g' : 'gi';
let wordsPattern = Array.from(wordMap.keys()).map(escapeRegex).join('|');
if (matchWhole) {
wordsPattern = `\\b(?:${wordsPattern})\\b`;
} }
let flags = matchCase ? 'gu' : 'giu';
let wordsPattern = Array.from(wordMap.keys()).map(escapeRegex).join('|');
if (matchWhole) {
wordsPattern = `(?:(?<!\\p{L})|^)(${wordsPattern})(?:(?!\\p{L})|$)`;
}
try {
const pattern = new RegExp(`(${wordsPattern})`, flags); const pattern = new RegExp(`(${wordsPattern})`, flags);
for (const node of textNodes) { for (const node of textNodes) {
if (!pattern.test(node.nodeValue)) continue; if (!node.nodeValue || !pattern.test(node.nodeValue)) continue;
const span = document.createElement('span'); const span = document.createElement('span');
span.innerHTML = node.nodeValue.replace(pattern, match => { span.innerHTML = node.nodeValue.replace(pattern, match => {
const word = wordMap.get(match.toLowerCase()) || { background: '#ffff00', foreground: '#000000' }; const lookup = matchCase ? match : match.toLowerCase();
const word = wordMap.get(lookup) || { background: '#ffff00', foreground: '#000000' };
return `<mark data-gh style="background:${word.background};color:${word.foreground};padding:0 2px;">${match}</mark>`; return `<mark data-gh style="background:${word.background};color:${word.foreground};padding:0 2px;">${match}</mark>`;
}); });
node.parentNode.replaceChild(span, node); node.parentNode.replaceChild(span, node);
} }
} catch (e) {
console.error("Regex error:", e);
}
} }
observer.observe(document.body, { observer.observe(document.body, {

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.6.0", "version": "1.7.1",
"default_locale": "en", "default_locale": "en",
"permissions": [ "permissions": [
"scripting", "scripting",