Compare commits

..

No commits in common. "42566713cfacdcc690cf78de9e4079705d802b44" and "77221513b5dff07d183af7f2ee1cde670cfabfef" have entirely different histories.

2 changed files with 6 additions and 42 deletions

View File

@ -1,30 +0,0 @@
A simple no-HTML random Hatsune Miku image server: https://random-miku.owo39.me/
Click reload to get a different one. Delete left half of URL to get to source.
Include pornographic results: https://random-miku.owo39.me/?allow_r18
If you're a pervert: https://random-miku.owo39.me/?allow_r18=only
Get different sizes (original, regular, small, or thumb_mini): https://random-miku.owo39.me/?size=thumb_mini
Auto-refresh using HTTP Refresh header: https://random-miku.owo39.me/?auto=3
kek: https://random-miku.owo39.me/?allow_r18&size=thumb_mini&auto=0
See your history: https://random-miku.owo39.me/log
Load image by id without redirect thing: https://random-miku.owo39.me/img/51586149
Load random image without redirect thing: https://random-miku.owo39.me/img/random
## Issues
- Browser back button is not useful
- HTTP Refresh does not save to browser history
## todo
- Proper HTML site that's more user-friendly

View File

@ -11,25 +11,19 @@ app.use(serveFavicon("ミク.png"));
app.use((req,res,next)=>{req.rawQuery = req.url.includes('?') && req.url.substr(req.url.indexOf('?')+1);next();});
var list = require("./list.json");
var list_r18_indices = [], list_safe_indices = [];
for (let i = 0, h = list.length; i < h; i++) if (list[i][2]) list_r18_indices.push(i); else list_safe_indices.push(i);
var ipa_lastload_map = {};
function getRandomId(allow_r18) {
if (allow_r18?.toLowerCase() == "only") {
return list[list_r18_indices[Math.floor(Math.random() * list_r18_indices.length)]][0];
} else if (allow_r18 != null) {
return list[Math.floor(Math.random() * list.length)][0];
} else {
return list[list_safe_indices[Math.floor(Math.random() * list_safe_indices.length)]][0];
}
var i = list[Math.floor(Math.random() * list.length)];
if (i[2] && !allow_r18) return getRandomId();
return i[0];
};
function getRandomUrl(req) {
var s = req?.params.settings ? `/${req?.params.settings}` : '';
var d = getRandomId(req?.query.allow_r18);
var d = getRandomId(req?.query.allow_r18!=null);
return `${s}/https://www.pixiv.net/en/artworks/${d}`;
}
@ -102,7 +96,7 @@ app.get('/', (req, res) => {
// direct random image without redirects
app.get("/img/random", (req, res, next) => {
serveId(getRandomId(req.query.allow_r18), req, res, next);
serveId(getRandomId(req.query.allow_r18!=null), req, res, next);
});
// simple serve id without redirects
@ -112,7 +106,7 @@ app.get("/img/:id", (req, res, next) => {
// plaintext random id for scripts
app.get("/randomid", function (req, res) {
res.type("text/plain").send(getRandomId(req.query.allow_r18));
res.type("text/plain").send(getRandomId(req.query.allow_r18!=null));
});