// Script that bypasses Image Pending Approval
'use strict';
function get_post_id(post) {
return post.id.replace('reply_', '').replace('thread_', '');
}
function get_thread_id(post) {
return post.closest('.thread').id.replace('thread_', '');
}
function get_image_data(json, post_id, image_index) {
const post_data = json.posts.find(elem => elem.no == post_id);
if (image_index == 0) {
return {
"tn_h": post_data.tn_h,
"tn_w": post_data.tn_w,
"h": post_data.h,
"w": post_data.w,
"fsize": post_data.fsize,
"thumb": post_data.thumb,
"filename": post_data.filename,
"ext": post_data.ext,
"tim": post_data.tim,
"md5": post_data.md5
};
}
return post_data['extra_files'][image_index - 1];
}
function bind_image_values_to_template(tn_h, tn_w, h, w, fsize, thumb, filename, ext, tim, md5) {
return `
`;
}
async function reveal(thread_id, post_id, image_index, image) {
const url = `https://${location.hostname}/${board_name}/thread/${thread_id}.json`;
const response = await fetch(url);
const json = await response.json();
const image_data = get_image_data(json, post_id, image_index);
image.outerHTML = bind_image_values_to_template(
image_data.tn_h,
image_data.tn_w,
image_data.h,
image_data.w,
image_data.fsize,
image_data.thumb,
image_data.filename,
image_data.ext,
image_data.tim,
image_data.md5
);
}
function bind_unapproved() {
const posts = document.querySelectorAll('.post.reply, .thread');
posts.forEach(elem => {
const images = elem.getElementsByClassName('post-image');
const thread_id = get_thread_id(elem);
const post_id = get_post_id(elem);
for (let i = 0; i < images.length; i++) {
if (images[i].classList.contains('unapproved')) {
images[i].onclick = () => {
reveal(thread_id, post_id, i, images[i]);
}
images[i]['src'] = 'https://files.catbox.moe/qwbpb5.jpg';
}
}
});
}
bind_unapproved();