Skip to content

Instantly share code, notes, and snippets.

@AprilSylph
Last active August 6, 2021 16:17
Show Gist options
  • Save AprilSylph/c450fb853e4e0b073274dde6e4d0f25a to your computer and use it in GitHub Desktop.
Save AprilSylph/c450fb853e4e0b073274dde6e4d0f25a to your computer and use it in GitHub Desktop.
XKit Extension
//* TITLE Banned! **//
//* VERSION 2.0.1 **//
//* DESCRIPTION Changes "Deactivated" labels to 4chan ban labels where appropriate **//
//* DEVELOPER AprilSylph **//
//* FRAME false **//
//* BETA false **//
XKit.extensions.banned = new Object({
running: false,
run: function() {
this.running = true;
this.check();
XKit.post_listener.add("banned", this.check);
},
cache: {},
check: function() {
var cache = XKit.extensions.banned.cache;
const apply_label = $deactivated => $deactivated
.css("color", "red")
.css("opacity", "1")
.html("(USER WAS BANNED FOR THIS POST)");
$(`.reblog-avatar.inactive > img:not(.xbanned-checked):not([src*="/default_avatar/"])`).each(function() {
const $username = $(this).addClass("xbanned-checked").parents(".reblog-list-item").find(".reblog-tumblelog-name");
let $deactivated = $username.find(".reblog-tumblelog-deactivated-status");
const deactivated_html = $deactivated[0].outerHTML;
$deactivated.remove();
const username = $username.text().trim();
$username.append(deactivated_html);
$deactivated = $username.find(".reblog-tumblelog-deactivated-status");
if (cache[username]) {
apply_label($deactivated);
} else if (cache[username] === undefined) {
XKit.svc.indash_blog({
tumblelog_name_or_id: username,
limit: 0
})
.then(() => {
cache[username] = false;
})
.catch(response => {
if (response.status === 404) {
cache[username] = true;
apply_label($deactivated);
}
});
}
});
},
destroy: function() {
this.running = false;
$(".reblog-tumblelog-deactivated-status[style]").removeAttr("style").html("Deactivated");
XKit.post_listener.remove("banned");
}
});
@AprilSylph
Copy link
Author

Note: this does not work on Tumblr's new React-based web interface, which launched April 2020.

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