Compare commits
2 Commits
77221513b5
...
42566713cf
Author | SHA1 | Date | |
---|---|---|---|
42566713cf | |||
9d8d5c078e |
30
README.md
Normal file
30
README.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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
|
18
index.js
18
index.js
@ -11,19 +11,25 @@ app.use(serveFavicon("ミク.png"));
|
|||||||
app.use((req,res,next)=>{req.rawQuery = req.url.includes('?') && req.url.substr(req.url.indexOf('?')+1);next();});
|
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 = 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 = {};
|
var ipa_lastload_map = {};
|
||||||
|
|
||||||
|
|
||||||
function getRandomId(allow_r18) {
|
function getRandomId(allow_r18) {
|
||||||
var i = list[Math.floor(Math.random() * list.length)];
|
if (allow_r18?.toLowerCase() == "only") {
|
||||||
if (i[2] && !allow_r18) return getRandomId();
|
return list[list_r18_indices[Math.floor(Math.random() * list_r18_indices.length)]][0];
|
||||||
return i[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];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function getRandomUrl(req) {
|
function getRandomUrl(req) {
|
||||||
var s = req?.params.settings ? `/${req?.params.settings}` : '';
|
var s = req?.params.settings ? `/${req?.params.settings}` : '';
|
||||||
var d = getRandomId(req?.query.allow_r18!=null);
|
var d = getRandomId(req?.query.allow_r18);
|
||||||
return `${s}/https://www.pixiv.net/en/artworks/${d}`;
|
return `${s}/https://www.pixiv.net/en/artworks/${d}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +102,7 @@ app.get('/', (req, res) => {
|
|||||||
|
|
||||||
// direct random image without redirects
|
// direct random image without redirects
|
||||||
app.get("/img/random", (req, res, next) => {
|
app.get("/img/random", (req, res, next) => {
|
||||||
serveId(getRandomId(req.query.allow_r18!=null), req, res, next);
|
serveId(getRandomId(req.query.allow_r18), req, res, next);
|
||||||
});
|
});
|
||||||
|
|
||||||
// simple serve id without redirects
|
// simple serve id without redirects
|
||||||
@ -106,7 +112,7 @@ app.get("/img/:id", (req, res, next) => {
|
|||||||
|
|
||||||
// plaintext random id for scripts
|
// plaintext random id for scripts
|
||||||
app.get("/randomid", function (req, res) {
|
app.get("/randomid", function (req, res) {
|
||||||
res.type("text/plain").send(getRandomId(req.query.allow_r18!=null));
|
res.type("text/plain").send(getRandomId(req.query.allow_r18));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user