4CHAN-FULL ?
www.4chan.org non-official read only api.
npm install 4chan-full
Custom Request Handler (new FourChanFull(yourHandler)
);
Get Thread (.thread(boardCode, threadId)
)
Watching Thread for Updates (.threadWatcher(boardCode, threadId, [options])
);
Get Board (.board(boardCode, page)
)
Get Archive (.archive(boardCode)
)
Get Popular Threads (.popular(safetyType)
)
Get Stats (.stats()
)
Board List (.boards
)
That small script lists all files of the thread..
const { fchf } = require("4chan-full");
(async () => {
const thread = await fchf.thread("wg", "7694540");
// thread.file -> Thread owner (OP) file.
// thread.replies[?].file -> reply file.
const files = [thread.file, ...thread.replies.map((i) => i?.file)].filter(
(i) => i != null
);
console.log(files);
})();
That small script watches the thread for new replies..
const { fchf } = require("4chan-full");
(async () => {
let watcher = fchf.threadWatcher("vg", "337012489");
// Events: updated, nowUpdated, checked, error, #start, #stop
watcher.on("updated", (oldThread, newThread) => {
console.log({ oldThread, newThread });
});
watcher.on("notUpdated", () => {
console.log("there is no new replies..");
});
watcher.on("checked", (oldThread, newThread) => {
console.log("checked new checkInterval:", watcher.checkInterval);
});
watcher.start();
})();