Last active
December 26, 2023 16:48
-
-
Save Chunjee/9efc99580c74b4cc7c6b3bf29af3d423 to your computer and use it in GitHub Desktop.
Something-Awful-threadSniper userscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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