Compare commits
2 Commits
28799f54bd
...
781350d089
Author | SHA1 | Date |
---|---|---|
|
781350d089 | |
|
bafe02b7cb |
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "metamorpov",
|
"name": "metamorpov",
|
||||||
"title": "MetamorPOV",
|
"title": "MetamorPOV",
|
||||||
"version": "1.2.0",
|
"version": "1.4.0",
|
||||||
"description": "Enables customization of reader-insert stories by replacing author-provided hooks such as Y/n, pov/s, and vrb/do/present/.",
|
"description": "Enables customization of reader-insert stories by replacing author-provided hooks such as Y/n, pov/s, and vrb/do/present/.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "MetamorPOV",
|
"name": "MetamorPOV",
|
||||||
"author": "Jean Viscogliosi-Pate",
|
"author": "Jean Viscogliosi-Pate",
|
||||||
"version": "1.3.0",
|
"version": "1.4.0",
|
||||||
|
|
||||||
"description": "Enables customization of reader-insert stories by replacing author-provided hooks such as Y/n, pov/s, and vrb/do/present/.",
|
"description": "Enables customization of reader-insert stories by replacing author-provided hooks such as Y/n, pov/s, and vrb/do/present/.",
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "MetamorPOV",
|
"name": "MetamorPOV",
|
||||||
"author": "Jean Viscogliosi-Pate",
|
"author": "Jean Viscogliosi-Pate",
|
||||||
"version": "1.3.0",
|
"version": "1.4.0",
|
||||||
|
|
||||||
"description": "Enables customization of reader-insert stories by replacing author-provided hooks such as Y/n, pov/s, and vrb/do/present/.",
|
"description": "Enables customization of reader-insert stories by replacing author-provided hooks such as Y/n, pov/s, and vrb/do/present/.",
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ function replaceAll() {
|
||||||
|
|
||||||
if (isAllSet) {
|
if (isAllSet) {
|
||||||
replaceExceptions(options);
|
replaceExceptions(options);
|
||||||
|
replaceEquals();
|
||||||
replaceCuts();
|
replaceCuts();
|
||||||
replaceCapitals();
|
replaceCapitals();
|
||||||
replaceMirror();
|
replaceMirror();
|
||||||
|
@ -230,6 +231,12 @@ function replaceExceptions(options) {
|
||||||
walk(document.body, searchTerm, options, exceptionMethod);
|
walk(document.body, searchTerm, options, exceptionMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Replaces statements by whether they match requested terms */
|
||||||
|
function replaceEquals() {
|
||||||
|
const searchTerm = /eql\/([\w\s]+)\/([\w\s]+)\/([^\/]*)\/(?:([^\/]*)\/)?/i;
|
||||||
|
walk(document.body, searchTerm, null, equalsMethod);
|
||||||
|
}
|
||||||
|
|
||||||
/* Replaces cut statements with cuts */
|
/* Replaces cut statements with cuts */
|
||||||
function replaceCuts() {
|
function replaceCuts() {
|
||||||
const searchTerm = /cut\/([^\/]+)\/(off|only) (first|last) ([1-9][0-9]*)\//i;
|
const searchTerm = /cut\/([^\/]+)\/(off|only) (first|last) ([1-9][0-9]*)\//i;
|
||||||
|
@ -375,13 +382,27 @@ function exceptionMethod(node, searchTerm, options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
||||||
exceptionMethod(node, searchTerm, options);
|
exceptionMethod(node, searchTerm, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allows for custom answers to custom words */
|
||||||
|
function equalsMethod(node, searchTerm, unused) {
|
||||||
|
const match = node.nodeValue.match(searchTerm);
|
||||||
|
if (match == null) { return; }
|
||||||
|
let replaceValue;
|
||||||
|
|
||||||
|
const isEqual = match[1] === match[2];
|
||||||
|
if (isEqual) {
|
||||||
|
replaceValue = match[3];
|
||||||
|
} else {
|
||||||
|
replaceValue = match[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
node.nodeValue = node.nodeValue.replace(searchTerm, replaceValue);
|
||||||
|
exceptionMethod(node, searchTerm, unused);
|
||||||
|
}
|
||||||
|
|
||||||
/* Allows for custom words to be truncated */
|
/* Allows for custom words to be truncated */
|
||||||
function cutMethod(node, searchTerm, unused) {
|
function cutMethod(node, searchTerm, unused) {
|
||||||
const match = node.nodeValue.match(searchTerm);
|
const match = node.nodeValue.match(searchTerm);
|
||||||
|
|
Loading…
Reference in New Issue