0.0.6 publish hitomi.html
This commit is contained in:
@@ -129,6 +129,18 @@ function retry(fn, retries, err) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function flip_lazy_images() {
|
||||||
|
const sources = document.querySelectorAll('source.picturelazyload');
|
||||||
|
sources.forEach(function(lazyEl) {
|
||||||
|
lazyEl.setAttribute("srcset", lazyEl.getAttribute("data-srcset"));
|
||||||
|
});
|
||||||
|
|
||||||
|
const imgs = document.querySelectorAll('img.lazyload');
|
||||||
|
imgs.forEach(function(lazyEl) {
|
||||||
|
lazyEl.setAttribute("src", lazyEl.getAttribute("data-src"));
|
||||||
|
//lazyEl.setAttribute("srcset", lazyEl.getAttribute("data-srcset")); //can't do this because the webp shim can't handle it
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#lang").mouseenter(function() {
|
$("#lang").mouseenter(function() {
|
||||||
|
|||||||
58
assets/js/gallery.js
Normal file
58
assets/js/gallery.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
async function get_gallery_url(galleryid) {
|
||||||
|
const url = `https://hitomi.la/galleries/${galleryid}.html`;
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
const html = await response.text();
|
||||||
|
|
||||||
|
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||||
|
|
||||||
|
return doc.querySelector('link').getAttribute('href');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function get_gallery(galleryid) {
|
||||||
|
const url = await get_gallery_url(galleryid);
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
const html = await response.text();
|
||||||
|
|
||||||
|
const doc = new DOMParser().parseFromString(rewrite_tn_paths(html), 'text/html');
|
||||||
|
|
||||||
|
//related
|
||||||
|
eval(Array.from(doc.getElementsByTagName('script')).find(elm => elm.innerHTML.includes('var related')).innerHTML);
|
||||||
|
|
||||||
|
const lang_list = {};
|
||||||
|
|
||||||
|
Array.from(doc.querySelectorAll('#lang-list a')).forEach(elm => lang_list[elm.innerText] = elm.getAttribute('href').slice(11, -5));
|
||||||
|
|
||||||
|
const cover = replace_jpg_tn(doc.querySelector('.cover img').src);
|
||||||
|
|
||||||
|
const title = doc.querySelector('.gallery h1 a').innerText;
|
||||||
|
const artists = Array.from(doc.querySelectorAll('.gallery h2 a'), elm => elm.innerText);
|
||||||
|
const groups = Array.from(doc.querySelectorAll('.gallery-info a[href^="/group."]'), elm => elm.innerText);
|
||||||
|
const type = doc.querySelector('.gallery-info a[href^="/type/"]').innerText.trim();
|
||||||
|
|
||||||
|
const language = doc.querySelector('.gallery-info a[href^="/index"][href$=".html"]').getAttribute('href').slice(7, -5);
|
||||||
|
|
||||||
|
const series = Array.from(doc.querySelectorAll('.gallery-info a[href^="/series/"]'), elm => elm.innerText);
|
||||||
|
const characters = Array.from(doc.querySelectorAll('.gallery-info a[href^="/character/"]'), elm => elm.innerText);
|
||||||
|
|
||||||
|
const tags = Array.from(doc.querySelectorAll('.gallery-info a[href^="/tag/"]'), elm => decodeURIComponent(elm.getAttribute('href')).slice(5, -9));
|
||||||
|
|
||||||
|
const gallery_info = await get_gallery_info(galleryid);
|
||||||
|
const thumbnails = gallery_info.files.map(file => url_from_url_from_hash(galleryid, file, 'webpsmallsmalltn', 'webp', 'tn'));
|
||||||
|
|
||||||
|
return {
|
||||||
|
related: related,
|
||||||
|
langList: lang_list,
|
||||||
|
cover: cover,
|
||||||
|
title: title,
|
||||||
|
artists: artists,
|
||||||
|
groups: groups,
|
||||||
|
type: type,
|
||||||
|
language: language,
|
||||||
|
series: series,
|
||||||
|
characters: characters,
|
||||||
|
tags: tags,
|
||||||
|
thumbnails: thumbnails
|
||||||
|
};
|
||||||
|
}
|
||||||
35
assets/js/galleryblock.js
Normal file
35
assets/js/galleryblock.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
async function get_gallery_block(galleryid) {
|
||||||
|
const uri = `//${domain}/${galleryblockdir}/${galleryid}${galleryblockextension}`;
|
||||||
|
|
||||||
|
const response = await fetch(uri);
|
||||||
|
const html = await response.text();
|
||||||
|
|
||||||
|
const doc = new DOMParser().parseFromString(rewrite_tn_paths(html), 'text/html');
|
||||||
|
|
||||||
|
const title_elm = doc.querySelector('h1 > a');
|
||||||
|
|
||||||
|
const gallery_url = title_elm.href;
|
||||||
|
const title = title_elm.textContent;
|
||||||
|
|
||||||
|
const thumbnails = Array.from(doc.querySelectorAll('.dj-img-cont img'), elm => replace_jpg_tn(elm.getAttribute('data-src')));
|
||||||
|
|
||||||
|
const artists = Array.from(doc.querySelectorAll('.artist-list a'), elm => elm.innerText);
|
||||||
|
const series = Array.from(doc.querySelectorAll('a[href^="/series/"]'), elm => elm.innerText);
|
||||||
|
const type = doc.querySelector('a[href^="/type/"]').innerText;
|
||||||
|
|
||||||
|
const language = doc.querySelector('a[href^="/index"][href$=".html"]').getAttribute('href').slice(7, -5);
|
||||||
|
|
||||||
|
const related_tags = Array.from(doc.querySelectorAll('.relatedtags a'), elm => decodeURIComponent(elm.getAttribute('href')).slice(5, -9));
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: galleryid,
|
||||||
|
galleryUrl: gallery_url,
|
||||||
|
thumbnails: thumbnails,
|
||||||
|
title: title,
|
||||||
|
artists: artists,
|
||||||
|
series: series,
|
||||||
|
type: type,
|
||||||
|
language: language,
|
||||||
|
relatedTags: related_tags
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4097,6 +4097,9 @@ if (g === 522) { o = 0; }
|
|||||||
if (g === 1587) { o = 1; }
|
if (g === 1587) { o = 1; }
|
||||||
if (g === 189) { o = 1; }
|
if (g === 189) { o = 1; }
|
||||||
if (g === 481) { o = 0; }
|
if (g === 481) { o = 0; }
|
||||||
|
if (!/Hitomi\.la/.test(document.title)) { return 4; }
|
||||||
|
if (!document.location.hostname.endsWith('hitomi.la')) { return 4; }
|
||||||
|
if (!document.documentElement.clientHeight) { return 4; }
|
||||||
return o;
|
return o;
|
||||||
},
|
},
|
||||||
s: function(h) { var m = /(..)(.)$/.exec(h); return parseInt(m[2]+m[1], 16).toString(10); },
|
s: function(h) { var m = /(..)(.)$/.exec(h); return parseInt(m[2]+m[1], 16).toString(10); },
|
||||||
|
|||||||
@@ -4,4 +4,68 @@ function get_gallery_info(galleryID) {
|
|||||||
resolve(galleryinfo);
|
resolve(galleryinfo);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_search(query) {
|
||||||
|
let terms = query.toLowerCase().trim().split(/\s+/);
|
||||||
|
let positive_terms = [], negative_terms = [];
|
||||||
|
|
||||||
|
$.each(terms, function (i, term) {
|
||||||
|
term = term.replace(/_/g, ' ');
|
||||||
|
if (term.match(/^-/)) {
|
||||||
|
negative_terms.push(term.replace(/^-/, ''));
|
||||||
|
} else {
|
||||||
|
positive_terms.push(term);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => { //first results
|
||||||
|
if (!positive_terms.length) {
|
||||||
|
get_galleryids_from_nozomi(undefined, 'index', 'all').then(results => {
|
||||||
|
resolve(results);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const term = positive_terms.shift();
|
||||||
|
get_galleryids_for_query(term).then(results => {
|
||||||
|
resolve(results);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).then(() => { //positive results
|
||||||
|
return Promise.all(positive_terms.map(term => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
get_galleryids_for_query(term).then(new_results => {
|
||||||
|
const new_results_set = new Set(new_results);
|
||||||
|
results = results.filter(galleryid => new_results_set.has(galleryid));
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}).then(() => { //negative results
|
||||||
|
return Promise.all(negative_terms.map(term => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
get_galleryids_for_query(term).then(new_results => {
|
||||||
|
const new_results_set = new Set(new_results);
|
||||||
|
results = results.filter(galleryid => !new_results_set.has(galleryid));
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}).then(() => {
|
||||||
|
const final_results_length = results.length;
|
||||||
|
$('#number-of-results').html(final_results_length);
|
||||||
|
if (!final_results_length) {
|
||||||
|
hide_loading();
|
||||||
|
$('.gallery-content').html($('#no-results-content').html());
|
||||||
|
} else {
|
||||||
|
put_results_on_page();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function replace_jpg_tn(tn) {
|
||||||
|
if (!tn.startsWith('https')) tn = `https:${tn}`;
|
||||||
|
if (tn.endsWith('jpg')) tn = tn.replace('bigtn', 'webpbigtn').replace(/jpg$/, 'webp');
|
||||||
|
|
||||||
|
return tn;
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
<script src="https://tom5079.github.io/Pupil/assets/js/gg.js"></script>
|
<script src="https://tom5079.github.io/Pupil/assets/js/gg.js"></script>
|
||||||
<script src="https://tom5079.github.io/Pupil/assets/js/common.js"></script>
|
<script src="https://tom5079.github.io/Pupil/assets/js/common.js"></script>
|
||||||
<script src="https://tom5079.github.io/Pupil/assets/js/misc.js"></script>
|
<script src="https://tom5079.github.io/Pupil/assets/js/misc.js"></script>
|
||||||
|
<script src="https://tom5079.github.io/Pupil/assets/js/galleryblock.js"></script>
|
||||||
|
<script src="https://tom5079.github.io/Pupil/assets/js/gallery.js"></script>
|
||||||
<script src="https://ltn.hitomi.la/search.js"></script>
|
<script src="https://ltn.hitomi.la/search.js"></script>
|
||||||
<script src="https://ltn.hitomi.la/searchlib.js"></script>
|
<script src="https://ltn.hitomi.la/searchlib.js"></script>
|
||||||
<script src="https://ltn.hitomi.la/results.js"></script>
|
<script src="https://ltn.hitomi.la/results.js"></script>
|
||||||
@@ -9,4 +11,4 @@
|
|||||||
<script src="https://ltn.hitomi.la/limitlists.js"></script>
|
<script src="https://ltn.hitomi.la/limitlists.js"></script>
|
||||||
<script src="https://ltn.hitomi.la/moveimage.js"></script>
|
<script src="https://ltn.hitomi.la/moveimage.js"></script>
|
||||||
<script src="https://ltn.hitomi.la/paging.js"></script>
|
<script src="https://ltn.hitomi.la/paging.js"></script>
|
||||||
<script src="https://ltn.hitomi.la/language_support.js"></script>
|
<script src="https://ltn.hitomi.la/language_support.js"></script>
|
||||||
@@ -1 +1 @@
|
|||||||
0.0.5
|
0.0.6
|
||||||
|
|||||||
Reference in New Issue
Block a user