Created
October 1, 2022 05:51
-
-
Save mrfoxtalbot/50b33a018af2f885023bb4683f993369 to your computer and use it in GitHub Desktop.
WordPress.org plugins topic highlighter
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 WordPress.org plugins topic highlighter | |
// @namespace http://clorith.net/ | |
// @version 0.1 | |
// @description Add status highlights to topics for easy overviews. | |
// @author Clorith | |
// @match https://wordpress.org/support/* | |
// @require https://code.jquery.com/jquery-1.11.0.min.js | |
// @grant none | |
// ==/UserScript== | |
jQuery(document).ready(function( $ ) { | |
/* | |
* The rules here are cascading, later rules will overwrite earlier ones. | |
* This is doen t oensure the right priority is applied, as some states are more important than others. | |
*/ | |
var text, $topics; | |
// Highlight topics that are more than a week old. | |
$topics = $( '.bbp-topic-freshness' ); | |
$topics.each(function() { | |
text = $( 'a', $(this) ).text(); | |
if ( text.includes( 'week' ) || text.includes( 'month' ) || text.includes( 'year' ) ) { | |
$(this).closest( 'ul' ).css( 'background-color', '#ffc173' ); | |
} | |
}); | |
// Highlight topics not yet replied to. | |
$topics = $( '.bbp-topic-voice-count' ); | |
$topics.each(function() { | |
text = $(this).text(); | |
if ( '1' === text ) { | |
$(this).closest( 'ul' ).css( 'background-color', '#ffeb00' ); | |
} | |
}); | |
// Highlight resolved threads. | |
$( 'span.resolved' ).closest( 'ul' ).css( 'background-color', 'rgb(203, 255, 181)' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment