Skip to content

Commit

Permalink
chore(release): 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EnergoStalin committed Nov 3, 2024
1 parent 20ddd85 commit 41e9b31
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
46 changes: 29 additions & 17 deletions index.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @author EnergoStalin
// @description Add kemono.su patreon & fanbox & fantia links into ppixiv
// @license AGPL-3.0-only
// @version 1.6.0
// @version 1.6.1
// @namespace https://pixiv.net
// @match https://*.pixiv.net/*
// @run-at document-body
Expand Down Expand Up @@ -40,13 +40,24 @@
};

// src/kemono.ts
function lastPostTimeFromHtml(html) {
const datetime = html.match(/datetime="(.+) /);
if (!datetime)
return "Could not determine last post datetime";
return datetime[1];
function toApiUrl(u) {
const url = new URL(u);
url.pathname = `/api/v1${url.pathname}/profile`;
return url.toString();
}
__name(lastPostTimeFromHtml, "lastPostTimeFromHtml");
__name(toApiUrl, "toApiUrl");
function getCreatorData(u) {
return __async(this, null, function* () {
const url = toApiUrl(u);
const response = yield GM.xmlHttpRequest({
url
});
if (response.status === 404)
throw "Creator dont exists";
return JSON.parse(response.responseText);
});
}
__name(getCreatorData, "getCreatorData");

// src/utils.ts
function normalizeUrl(url) {
Expand Down Expand Up @@ -129,16 +140,17 @@
var cachedRequests = {};
function cacheRequest(url) {
return __async(this, null, function* () {
const response = yield GM.xmlHttpRequest({
method: "GET",
redirect: "manual",
url
});
const value = response.finalUrl !== url;
cachedRequests[url] = {
redirected: value,
lastUpdate: lastPostTimeFromHtml(response.responseText)
};
try {
const data = yield getCreatorData(url);
cachedRequests[url] = {
redirected: false,
lastUpdate: data.updated.split("T")[0]
};
} catch (e) {
cachedRequests[url] = {
redirected: true
};
}
});
}
__name(cacheRequest, "cacheRequest");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppixiv-kemono",
"version": "1.6.0",
"version": "1.6.1",
"description": "Add kemono.su patreon & fanbox & fantia links into ppixiv",
"homepage": "https://pixiv.net",
"module": "esm",
Expand Down

0 comments on commit 41e9b31

Please sign in to comment.