Skip to content

Instantly share code, notes, and snippets.

@nnuudev
Created September 13, 2021 18:48
Show Gist options
  • Select an option

  • Save nnuudev/69e4bd8e1c904c55ec9cc873354002ad to your computer and use it in GitHub Desktop.

Select an option

Save nnuudev/69e4bd8e1c904c55ec9cc873354002ad to your computer and use it in GitHub Desktop.
Add flags to the posts when viewing an archived thread on Desuarchive
// ==UserScript==
// @name Load /mlp/ flags on Desuarchive
// @namespace https://desuarchive.org/mlp/thread/
// @description Add flags to the posts when viewing an archived thread on Desuarchive
// @version 1.0
// @author Anonymous
// @icon https://s.4cdn.org/image/flags/mlp/anf.gif
// @match https://desuarchive.org/mlp/thread/*
// @run-at document-end
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
GM_addStyle(`
.post_poster_data img {
display: inline-block;
width: 16px;
height: 16px;
position: relative;
top: -2px;
}
`);
function addFlag(post) {
if ("exif" in post && post.exif !== null) {
let exif = JSON.parse(post.exif);
if ("troll_country_code" in exif && "troll_country_name" in exif) {
let board_flag = exif.troll_country_code;
let flag_name = exif.troll_country_name;
document.querySelector(`article[id='${post.num}'] .post_poster_data`).insertAdjacentHTML('beforeend', `<img
src="https://s.4cdn.org/image/flags/mlp/${board_flag.toLowerCase()}.gif"
alt="${board_flag}" title="${flag_name}" referrerPolicy="no-referrer">`);
}
}
}
$.getJSON(`${backend_vars.api_url}_/api/chan/thread/?board=${backend_vars.board_shortname}&num=${backend_vars.thread_id}`, data => {
let thread = data[backend_vars.thread_id];
addFlag(thread.op);
for (let postId in thread.posts) {
addFlag(thread.posts[postId]);
}
});
})();
@drunohazarb
Copy link
Copy Markdown

Don't know where else to share this so I'll just post it here:
https://files.catbox.moe/ebe8q4.zip

new_captcha.html with a captcha solver implemented, identical to the WASM version of: https://github.com/drunohazarb/4chan-captcha-solver
Works well when injected into Blue Clover's APK and is reasonably fast thanks to the wasm backend. I figured that you could implement this in your codebase better than I could.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment