Spaces:
Sleeping
Sleeping
Update public/script.js
Browse files- public/script.js +16 -12
public/script.js
CHANGED
|
@@ -126,12 +126,14 @@ async function fetchVideoDataById(videoId) {
|
|
| 126 |
}
|
| 127 |
|
| 128 |
async function fetchNextValidVideoData(tags, page) {
|
| 129 |
-
const
|
| 130 |
-
const
|
| 131 |
|
| 132 |
-
const response = await fetch(
|
| 133 |
if (!response.ok) return null;
|
| 134 |
-
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
function videoIsValid(video) {
|
|
@@ -535,14 +537,16 @@ activityCheck = setInterval(() => {
|
|
| 535 |
}, 250);
|
| 536 |
|
| 537 |
async function getTags() {
|
| 538 |
-
//
|
| 539 |
-
const
|
| 540 |
-
const
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
|
|
|
|
|
|
| 546 |
}
|
| 547 |
|
| 548 |
function putTagsInForm(tags) {
|
|
|
|
| 126 |
}
|
| 127 |
|
| 128 |
async function fetchNextValidVideoData(tags, page) {
|
| 129 |
+
const targetUrl = `https://www.sakugabooru.com/post.json?limit=1&page=${page}&tags=${tags}`;
|
| 130 |
+
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(targetUrl)}`;
|
| 131 |
|
| 132 |
+
const response = await fetch(proxyUrl);
|
| 133 |
if (!response.ok) return null;
|
| 134 |
+
|
| 135 |
+
const data = await response.json();
|
| 136 |
+
return JSON.parse(data.contents);
|
| 137 |
}
|
| 138 |
|
| 139 |
function videoIsValid(video) {
|
|
|
|
| 537 |
}, 250);
|
| 538 |
|
| 539 |
async function getTags() {
|
| 540 |
+
// AllOrigins uses a different format: hex/json wrapping
|
| 541 |
+
const targetUrl = "https://www.sakugabooru.com/tag.json?limit=1500&order=count";
|
| 542 |
+
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(targetUrl)}`;
|
| 543 |
+
|
| 544 |
+
const response = await fetch(proxyUrl);
|
| 545 |
+
if (!response.ok) return [];
|
| 546 |
+
|
| 547 |
+
const data = await response.json();
|
| 548 |
+
// AllOrigins wraps the result in a .contents string, so we must parse it
|
| 549 |
+
return JSON.parse(data.contents);
|
| 550 |
}
|
| 551 |
|
| 552 |
function putTagsInForm(tags) {
|