This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
.js
|
.js
|
||||||
|
plugins/multisrc/fictioneer/custom
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
const scriptContent = loadedCheerio('script')
|
||||||
|
.toArray()
|
||||||
|
.map(script => loadedCheerio(script).html())
|
||||||
|
.find(content => content && content.includes('var gib ='));
|
||||||
|
|
||||||
|
if (scriptContent) {
|
||||||
|
const gibMatch = scriptContent.match(/var gib = (\[.*?\])/);
|
||||||
|
if (gibMatch) {
|
||||||
|
const gibArray = eval(gibMatch[1]) as string[];
|
||||||
|
gibArray.forEach(cssClass => {
|
||||||
|
loadedCheerio(`.${cssClass}`).remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadedCheerio('ruby').remove();
|
||||||
|
|
||||||
|
loadedCheerio('section#chapter-content p *').each((_, el) => {
|
||||||
|
if (loadedCheerio(el).attr('data-fcnc-rev') !== '1') return;
|
||||||
|
const textContent = loadedCheerio(el).text().trim();
|
||||||
|
if (textContent) {
|
||||||
|
loadedCheerio(el).replaceWith(
|
||||||
|
Array.from(textContent).reverse().join(''),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
loadedCheerio('section#chapter-content > div')
|
||||||
|
.html()
|
||||||
|
?.normalize()
|
||||||
|
.replace(/\u00A0/g, ' ')
|
||||||
|
.replace(/\u2060/g, '')
|
||||||
|
.replace(//g, '') // ­
|
||||||
|
.replace(/[\u202F\u2007\u200B]/g, '') || ''
|
||||||
|
);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
|
|
||||||
@@ -20,8 +20,16 @@ const generator = function generator(source) {
|
|||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const chapterTransformJsOrPath = source.options?.customJs?.chapterTransform;
|
||||||
|
const chapterTransformPath = chapterTransformJsOrPath
|
||||||
|
? join(folder, chapterTransformJsOrPath)
|
||||||
|
: '';
|
||||||
|
const chapterTransformJs = existsSync(chapterTransformPath)
|
||||||
|
? readFileSync(chapterTransformPath, { encoding: 'utf-8' })
|
||||||
|
: chapterTransformJsOrPath;
|
||||||
|
|
||||||
const pluginScript = `
|
const pluginScript = `
|
||||||
${readNovelFullTemplate}
|
${readNovelFullTemplate.replace('// chapterTransformJs HERE', chapterTransformJs || '')}
|
||||||
const plugin = new FictioneerPlugin(${JSON.stringify(source)});
|
const plugin = new FictioneerPlugin(${JSON.stringify(source)});
|
||||||
export default plugin;
|
export default plugin;
|
||||||
`.trim();
|
`.trim();
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
"sourceSite": "https://lilyonthevalley.com",
|
"sourceSite": "https://lilyonthevalley.com",
|
||||||
"sourceName": "Lily on the Valley",
|
"sourceName": "Lily on the Valley",
|
||||||
"options": {
|
"options": {
|
||||||
|
"customJs": {
|
||||||
|
"chapterTransform": "custom/lillyonthevalley/chapterTransform.js"
|
||||||
|
},
|
||||||
|
"versionIncrements": 1,
|
||||||
"browsePage": "stories"
|
"browsePage": "stories"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ class FictioneerPlugin implements Plugin.PluginBase {
|
|||||||
const body = await req.text();
|
const body = await req.text();
|
||||||
|
|
||||||
const loadedCheerio = loadCheerio(body);
|
const loadedCheerio = loadCheerio(body);
|
||||||
|
|
||||||
|
// chapterTransformJs HERE
|
||||||
|
|
||||||
return loadedCheerio('section#chapter-content > div').html() || '';
|
return loadedCheerio('section#chapter-content > div').html() || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-1
@@ -118,5 +118,18 @@
|
|||||||
|
|
||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||||
},
|
},
|
||||||
"exclude": ["./plugins/**/*.broken.ts", "./.js/**/*", "scripts", "docs"]
|
"exclude": [
|
||||||
|
"./plugins/**/*.broken.ts",
|
||||||
|
"./.js/**/*",
|
||||||
|
"scripts/**",
|
||||||
|
"docs/**",
|
||||||
|
"./src/*.*",
|
||||||
|
"./*.*",
|
||||||
|
"public/**",
|
||||||
|
".github/**",
|
||||||
|
".husky/**",
|
||||||
|
"node_modules/**",
|
||||||
|
"./src/**",
|
||||||
|
"./plugins/multisrc/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@
|
|||||||
".github/**",
|
".github/**",
|
||||||
".husky/**",
|
".husky/**",
|
||||||
"node_modules/**",
|
"node_modules/**",
|
||||||
"./src/**"
|
"./src/**",
|
||||||
|
"./plugins/multisrc/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user