Compare commits
2 Commits
0a906d8432
...
94b04337be
Author | SHA1 | Date |
---|---|---|
|
94b04337be | |
|
0f716a4332 |
|
@ -14,6 +14,7 @@
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.nodejs_22
|
pkgs.nodejs_22
|
||||||
|
pkgs.firefox
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,6 +40,7 @@ function replaceAll() {
|
||||||
if (isAllSet) {
|
if (isAllSet) {
|
||||||
replaceExceptions(options);
|
replaceExceptions(options);
|
||||||
replaceCuts();
|
replaceCuts();
|
||||||
|
replaceCapitals();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -226,13 +227,18 @@ function replaceExceptions(options) {
|
||||||
walk(document.body, searchTerm, options, exceptionMethod);
|
walk(document.body, searchTerm, options, exceptionMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Replaces cut statements with cuts */
|
/* Replaces cut statements with cuts */
|
||||||
function replaceCuts() {
|
function replaceCuts() {
|
||||||
const searchTerm = /cut\/([^\/]+)\/(-?[\d]+)\//i;
|
const searchTerm = /cut\/([^\/]+)\/(-?[\d]+)\//i;
|
||||||
walk(document.body, searchTerm, null, cutMethod);
|
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 */
|
/* 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, "\\$&");
|
||||||
|
@ -331,6 +337,22 @@ function verbMethod(node, searchTerm, options) {
|
||||||
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 */
|
/* Allows for custom words to be cut off */
|
||||||
function cutMethod(node, searchTerm, unused) {
|
function cutMethod(node, searchTerm, unused) {
|
||||||
const match = node.nodeValue.match(searchTerm);
|
const match = node.nodeValue.match(searchTerm);
|
||||||
|
@ -355,20 +377,28 @@ function cutMethod(node, searchTerm, unused) {
|
||||||
cutMethod(node, searchTerm, unused);
|
cutMethod(node, searchTerm, unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allows for custom words to be cut off */
|
/* Allows for custom words to be capitalized */
|
||||||
function exceptionMethod(node, searchTerm, options) {
|
function capitalMethod(node, searchTerm, unused) {
|
||||||
const match = node.nodeValue.match(searchTerm);
|
const match = node.nodeValue.match(searchTerm);
|
||||||
if (match == null) { return; }
|
if (match == null) { return; }
|
||||||
|
const style = match[1];
|
||||||
|
const target = match[2];
|
||||||
|
const isLowerCase = /c/.test(style.slice(0,1)); // cap
|
||||||
|
|
||||||
let replaceValue;
|
let replaceValue;
|
||||||
if (options.pov == "third") {
|
if (isLowerCase) {
|
||||||
replaceValue = match[2];
|
replaceValue = target.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
replaceValue = match[1];
|
const isStartCase = /a/.test(style.slice(1,2)); // Cap
|
||||||
|
if (isStartCase) {
|
||||||
|
replaceValue = capitalize(target);
|
||||||
|
} else { // CAP
|
||||||
|
replaceValue = target.toUpperCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
||||||
exceptionMethod(node, searchTerm, options);
|
capitalMethod(node, searchTerm, unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the input word, capitalized */
|
/* Returns the input word, capitalized */
|
||||||
|
|
Loading…
Reference in New Issue