Compare commits

..

No commits in common. "94b04337bedfca82fb80eba21103b65993fd6256" and "0a906d84322ef7d2193db4ff5384c3677d887802" have entirely different histories.

3 changed files with 878 additions and 270 deletions

View File

@ -14,7 +14,6 @@
default = pkgs.mkShell {
buildInputs = [
pkgs.nodejs_22
pkgs.firefox
];
};
});

1103
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,6 @@ function replaceAll() {
if (isAllSet) {
replaceExceptions(options);
replaceCuts();
replaceCapitals();
}
});
}
@ -227,18 +226,13 @@ function replaceExceptions(options) {
walk(document.body, searchTerm, options, exceptionMethod);
}
/* Replaces cut statements with cuts */
function replaceCuts() {
const searchTerm = /cut\/([^\/]+)\/(-?[\d]+)\//i;
walk(document.body, searchTerm, null, cutMethod);
}
/* Replaces cut statements with cuts */
function replaceCapitals() {
const searchTerm = /(cap|Cap|CAP)\/([^\/]+)\//i;
walk(document.body, searchTerm, null, capitalMethod);
}
/* Turns a term into regexp format and uses that to replace it */
function escapeAndReplace(searchTerm, replaceValue, caseSensitive) {
let searchTermEscaped = searchTerm.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
@ -337,22 +331,6 @@ function verbMethod(node, searchTerm, options) {
verbMethod(node, searchTerm, options);
}
/* Allows for first, second, and third-person POV to read differently */
function exceptionMethod(node, searchTerm, options) {
const match = node.nodeValue.match(searchTerm);
if (match == null) { return; }
let replaceValue;
if (options.pov == "third") {
replaceValue = match[2];
} else {
replaceValue = match[1];
}
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
exceptionMethod(node, searchTerm, options);
}
/* Allows for custom words to be cut off */
function cutMethod(node, searchTerm, unused) {
const match = node.nodeValue.match(searchTerm);
@ -377,28 +355,20 @@ function cutMethod(node, searchTerm, unused) {
cutMethod(node, searchTerm, unused);
}
/* Allows for custom words to be capitalized */
function capitalMethod(node, searchTerm, unused) {
/* Allows for custom words to be cut off */
function exceptionMethod(node, searchTerm, options) {
const match = node.nodeValue.match(searchTerm);
if (match == null) { return; }
const style = match[1];
const target = match[2];
const isLowerCase = /c/.test(style.slice(0,1)); // cap
let replaceValue;
if (isLowerCase) {
replaceValue = target.toLowerCase();
if (options.pov == "third") {
replaceValue = match[2];
} else {
const isStartCase = /a/.test(style.slice(1,2)); // Cap
if (isStartCase) {
replaceValue = capitalize(target);
} else { // CAP
replaceValue = target.toUpperCase();
}
replaceValue = match[1];
}
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
capitalMethod(node, searchTerm, unused);
exceptionMethod(node, searchTerm, options);
}
/* Returns the input word, capitalized */