Adding a/an feature, fixes #39
This commit is contained in:
parent
fdcce37656
commit
9faabd6f0d
|
@ -1,4 +1,5 @@
|
||||||
node_modules
|
node_modules
|
||||||
src/content-script.js
|
src/content-script.js
|
||||||
src/popup.js
|
src/popup.js
|
||||||
|
src/manifest.json
|
||||||
dist
|
dist
|
||||||
|
|
11
README.md
11
README.md
|
@ -47,8 +47,9 @@ npm run test-chrome
|
||||||
|
|
||||||
## Copyright and License
|
## Copyright and License
|
||||||
|
|
||||||
- Portions of MetamorPOV are derived from [InteractiveFics](https://github.com/interactivefics/interactive-fics), licensed under [MIT](third-party-licenses/LICENSE-InteractiveFics), copyrighted 2015-2023 by Mariam Maarouf.
|
- Portions of MetamorPOV are derived from [InteractiveFics](https://github.com/interactivefics/interactive-fics), licensed under [MIT](third-party-licenses/LICENSE-InteractiveFics), copyrighted 2015–2023 by Mariam Maarouf.
|
||||||
- MetamorPOV supports verb conjugation with [RosaeNLG](https://rosaenlg.org/), licensed under [Apache-2.0](third-party-licenses/LICENSE-RosaeNLG), copyrighted 2019-2024 by Ludan Stoecklé, 2015 by Forbes Lindesay, and 2009-2014 by TJ Holowaychuk.
|
- MetamorPOV supports verb conjugation with [RosaeNLG](https://rosaenlg.org/), licensed under [Apache-2.0](third-party-licenses/LICENSE-RosaeNLG), copyrighted 2019-2024 by Ludan Stoecklé, 2015 by Forbes Lindesay, and 2009–2014 by TJ Holowaychuk.
|
||||||
- MetamorPOV is themed with [Primary](https://primary-theme.github.io/), licensed under [GPL-3.0](third-party-licenses/LICENSE-Primary), copyrighted 2021-2024 by Cecilia May.
|
- MetamorPOV supports adaptive articles with [indefinite](https://github.com/tandrewnichols/indefinite), licensed under [MIT](third-party-licenses/LICENSE-indefinite), copyrighted 2015–2025 by Andrew Nichols.
|
||||||
- Icons, excepting the butterfly, are redistributed from [Luicide](https://lucide.dev), licensed under [ISC](third-party-licenses/LICENSE-Luicide), copyrighted 2022-2025 by Lucide Contributors. Luicide contains portions of Feather, licensed under [MIT](third-party-licenses/LICENSE-Feather), copyrighted 2013-2022 by Cole Bemis.
|
- MetamorPOV is themed with [Primary](https://primary-theme.github.io/), licensed under [GPL-3.0](third-party-licenses/LICENSE-Primary), copyrighted 2021–2024 by Cecilia May.
|
||||||
- All other portions of MetamorPOV are licensed under [GPL-3.0-or-later](LICENSE), copyrighted 2024-2025 by Jean Viscogliosi-Pate.
|
- Icons, excepting the butterfly, are redistributed from [Luicide](https://lucide.dev), licensed under [ISC](third-party-licenses/LICENSE-Luicide), copyrighted 2022–2025 by Lucide Contributors. Luicide contains portions of Feather, licensed under [MIT](third-party-licenses/LICENSE-Feather), copyrighted 2013–2022 by Cole Bemis.
|
||||||
|
- All other portions of MetamorPOV are licensed under [GPL-3.0-or-later](LICENSE), copyrighted 2024–2025 by Jean Viscogliosi-Pate.
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"english-verbs-gerunds": "3.3.1",
|
"english-verbs-gerunds": "3.3.1",
|
||||||
"english-verbs-helper": "3.3.1",
|
"english-verbs-helper": "3.3.1",
|
||||||
"english-verbs-irregular": "3.3.1",
|
"english-verbs-irregular": "3.3.1",
|
||||||
|
"indefinite": "^2.5.1",
|
||||||
"rollup": "^4.27.3",
|
"rollup": "^4.27.3",
|
||||||
"web-ext": "^8.3.0",
|
"web-ext": "^8.3.0",
|
||||||
"webextension-polyfill": "^0.12.0"
|
"webextension-polyfill": "^0.12.0"
|
||||||
|
@ -2824,6 +2825,16 @@
|
||||||
"node": ">=0.8.19"
|
"node": ">=0.8.19"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/indefinite": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/indefinite/-/indefinite-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-Ul0hCdnSjuFDEloYWeozTaEfljbz+0q+u4HsHns2dOk2DlhGlbRMGFtNcIL+Ve7sZYeIOTOAKA0usAXBGHpNDg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/inflight": {
|
"node_modules/inflight": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"test": "cp src/manifest-firefox.json src/manifest.json && npx rollup -c && npx web-ext run -s src && rm src/manifest.json",
|
"test": "cp src/manifest-firefox.json src/manifest.json && npx rollup -c && npx web-ext run -s src && rm src/manifest.json",
|
||||||
"test-chrome": "cp src/manifest-chrome.json src/manifest.json && npx rollup -c && chromium && rm src/manifest.json",
|
"test-chrome": "cp src/manifest-chrome.json src/manifest.json && npx rollup -c && chromium && rm src/manifest.json",
|
||||||
"build": "cp src/manifest-firefox.json src/manifest.json && npx rollup -c && npx web-ext build -s src -a dist --ignore-files replace-words.js save-load-options.js manifest-* service-worker* -n {name}-{version}.xpi -o && rm src/manifest.json",
|
"build": "cp src/manifest-firefox.json src/manifest.json && npx rollup -c && npx web-ext build -s src -a dist --ignore-files replace-words.js save-load-options.js manifest-* service-worker* -n {name}-{version}.xpi -o && rm src/manifest.json",
|
||||||
"build-chrome": "cp src/manifest-chrome.json src/manifest.json && npx rollup -c && npx web-ext build -s src -a dist --ignore-files replace-words.js save-load-options.js manifest-* background.js -n {name}-{version}-chrome.zip -o && rm src/manifest.json"
|
"build-chrome": "cp src/manifest-chrome.json src/manifest.json && npx rollup -c && npx web-ext build -s src -a dist --ignore-files replace-words.js save-load-options.js manifest-* background.js -n {name}-{version}.zip -o && rm src/manifest.json"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "28.0.2",
|
"@rollup/plugin-commonjs": "28.0.2",
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
"english-verbs-gerunds": "3.3.1",
|
"english-verbs-gerunds": "3.3.1",
|
||||||
"english-verbs-helper": "3.3.1",
|
"english-verbs-helper": "3.3.1",
|
||||||
"english-verbs-irregular": "3.3.1",
|
"english-verbs-irregular": "3.3.1",
|
||||||
|
"indefinite": "^2.5.1",
|
||||||
"rollup": "^4.27.3",
|
"rollup": "^4.27.3",
|
||||||
"web-ext": "^8.3.0",
|
"web-ext": "^8.3.0",
|
||||||
"webextension-polyfill": "^0.12.0"
|
"webextension-polyfill": "^0.12.0"
|
||||||
|
|
|
@ -3,6 +3,7 @@ const verbsHelper = require("english-verbs-helper");
|
||||||
const verbsIrregular = require("english-verbs-irregular/dist/verbs.json");
|
const verbsIrregular = require("english-verbs-irregular/dist/verbs.json");
|
||||||
const verbsGerunds = require("english-verbs-gerunds/dist/gerunds.json");
|
const verbsGerunds = require("english-verbs-gerunds/dist/gerunds.json");
|
||||||
const verbsData = verbsHelper.mergeVerbsData(verbsIrregular, verbsGerunds);
|
const verbsData = verbsHelper.mergeVerbsData(verbsIrregular, verbsGerunds);
|
||||||
|
const articleHelper = require("indefinite");
|
||||||
|
|
||||||
/* Replaces verbs, point-of-view, name, pronouns, and "also" terms */
|
/* Replaces verbs, point-of-view, name, pronouns, and "also" terms */
|
||||||
function replaceAll() {
|
function replaceAll() {
|
||||||
|
@ -42,6 +43,7 @@ function replaceAll() {
|
||||||
replaceCuts();
|
replaceCuts();
|
||||||
replaceCapitals();
|
replaceCapitals();
|
||||||
replaceMirror();
|
replaceMirror();
|
||||||
|
replaceAn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -246,6 +248,12 @@ function replaceMirror() {
|
||||||
walk(document.body, searchTerm, null, mirrorMethod);
|
walk(document.body, searchTerm, null, mirrorMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Replaces ambiguous articles with one suitable to the following word */
|
||||||
|
function replaceAn() {
|
||||||
|
const searchTerm = /a\/an (\w+)/i;
|
||||||
|
walk(document.body, searchTerm, null, anMethod);
|
||||||
|
}
|
||||||
|
|
||||||
/* Turns a term into regexp format and uses that to replace it */
|
/* Turns a term into regexp format and uses that to replace it */
|
||||||
function escapeAndReplace(searchTerm, replaceValue, caseSensitive) {
|
function escapeAndReplace(searchTerm, replaceValue, caseSensitive) {
|
||||||
let searchTermEscaped = searchTerm.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
let searchTermEscaped = searchTerm.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||||
|
@ -445,6 +453,18 @@ function mirrorMethod(node, searchTerm, unused) {
|
||||||
mirrorMethod(node, searchTerm, unused);
|
mirrorMethod(node, searchTerm, unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allows for custom words to have the right article */
|
||||||
|
function anMethod(node, searchTerm, unused) {
|
||||||
|
const match = node.nodeValue.match(searchTerm);
|
||||||
|
if (match == null) { return; }
|
||||||
|
const target = match[1];
|
||||||
|
|
||||||
|
let replaceValue = articleHelper(target, { numbers: 'colloquial' });
|
||||||
|
|
||||||
|
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
||||||
|
mirrorMethod(node, searchTerm, unused);
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the input word, capitalized */
|
/* Returns the input word, capitalized */
|
||||||
function capitalize(word) {
|
function capitalize(word) {
|
||||||
return word.charAt(0).toUpperCase() + word.slice(1);
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 Andrew Nichols
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
Loading…
Reference in New Issue