Skip to content

Instantly share code, notes, and snippets.

@Chunjee
Last active December 26, 2023 16:48
Show Gist options
  • Save Chunjee/9efc99580c74b4cc7c6b3bf29af3d423 to your computer and use it in GitHub Desktop.
Save Chunjee/9efc99580c74b4cc7c6b3bf29af3d423 to your computer and use it in GitHub Desktop.
Something-Awful-threadSniper userscript
// ==UserScript==
// @name Something-Awful-threadSniper
// @version 0.2.0
// @description Highlights threads ready to be sniped
// @match *://forums.somethingawful.com/*
// @license MIT
// @grant none
// @namespace http://github.com/Chunjee
// @author Chunjee
// ==/UserScript==
var userpref_PostsPerPage = 40;
var $ = window.jQuery;
var specialForums = ["YOSPOS"]
$(document).ready(function() {
'use strict';
const specialForumCheck = $(".bclast").first().text();
const isSpecialForum = specialForums.includes(specialForumCheck);
$(".replies").each(function() {
const originalValue = Number($(this).text());
if (!isNaN(originalValue)) {
const value = originalValue % userpref_PostsPerPage;
const $elem = $(this);
// if value is greater than 37, highlight yellow
if (value > userpref_PostsPerPage - 3) {
if (isSpecialForum) {
$elem.text(originalValue).css("color", "yellow");
} else {
$elem.css("background-color", "yellow");
}
}
// if value is 40, highlight green (or red for YOSPOS)
if (value + 1 == userpref_PostsPerPage) {
if (isSpecialForum) {
$elem.text(originalValue).css("color", "red");
} else {
$elem.css("background-color", "green");
}
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment