Compare commits
No commits in common. "94b04337bedfca82fb80eba21103b65993fd6256" and "0a906d84322ef7d2193db4ff5384c3677d887802" have entirely different histories.
94b04337be
...
0a906d8432
|
@ -14,7 +14,6 @@
|
||||||
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,7 +40,6 @@ function replaceAll() {
|
||||||
if (isAllSet) {
|
if (isAllSet) {
|
||||||
replaceExceptions(options);
|
replaceExceptions(options);
|
||||||
replaceCuts();
|
replaceCuts();
|
||||||
replaceCapitals();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -227,18 +226,13 @@ 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, "\\$&");
|
||||||
|
@ -337,22 +331,6 @@ 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);
|
||||||
|
@ -377,28 +355,20 @@ function cutMethod(node, searchTerm, unused) {
|
||||||
cutMethod(node, searchTerm, unused);
|
cutMethod(node, searchTerm, unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allows for custom words to be capitalized */
|
/* Allows for custom words to be cut off */
|
||||||
function capitalMethod(node, searchTerm, unused) {
|
function exceptionMethod(node, searchTerm, options) {
|
||||||
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 (isLowerCase) {
|
if (options.pov == "third") {
|
||||||
replaceValue = target.toLowerCase();
|
replaceValue = match[2];
|
||||||
} else {
|
} else {
|
||||||
const isStartCase = /a/.test(style.slice(1,2)); // Cap
|
replaceValue = match[1];
|
||||||
if (isStartCase) {
|
|
||||||
replaceValue = capitalize(target);
|
|
||||||
} else { // CAP
|
|
||||||
replaceValue = target.toUpperCase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
||||||
capitalMethod(node, searchTerm, unused);
|
exceptionMethod(node, searchTerm, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the input word, capitalized */
|
/* Returns the input word, capitalized */
|
||||||
|
|
Loading…
Reference in New Issue