mirror of
https://github.com/2009scape/2009scape.github.io.git
synced 2024-10-27 06:02:31 +01:00
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
|
/*
|
||
|
HOW TO USE THIS SCRIPT:
|
||
|
|
||
|
Step 1: Put the script where you need it
|
||
|
Step 2: Set "replaceMenuBox" string to the right path (find and replace the number of ./../../'s)
|
||
|
Step 3: Make sure the files are being read from the right path based on the function below
|
||
|
|
||
|
Always use git. You will mess up your work first try.
|
||
|
*/
|
||
|
|
||
|
let fs = require('fs');
|
||
|
const dir = __dirname + '/m=news/'
|
||
|
files = fs.readdirSync(dir);
|
||
|
|
||
|
let replaceMenubox = `<div id="langAndLogin">
|
||
|
|
||
|
<div id="lang">
|
||
|
<a href="../../index.html"><img alt="English" title="English" src="../../site/img/main/layout/en.gif" /></a>
|
||
|
<a href="../../site/l%3d1/title.html"><img alt="Deutsch" title="Deutsch" src="../../site/img/main/layout/de.gif" /></a>
|
||
|
<a href="../../site/l%3d2/title.html"><img alt="Français" title="Français" src="../../site/img/main/layout/fr.gif" /></a>
|
||
|
<a href="../../site/l%3d3/title.html"><img alt="Português (BR)" title="Português (BR)" src="../../site/img/main/layout/br.gif" /></a>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="navigation">`
|
||
|
|
||
|
files.forEach(function (fileName) {
|
||
|
if (fs.lstatSync(dir + fileName).isFile()) {
|
||
|
let contents = fs.readFileSync(dir + fileName, 'utf8');
|
||
|
const regex = /<div id="langAndLogin">[\s\S]*<div class="navigation">/i;
|
||
|
fs.writeFileSync(dir + fileName, contents.replace("../../site/title.html", "../../index.html"));
|
||
|
}
|
||
|
})
|