Last active
March 25, 2022 10:50
-
-
Save panosru/f83c4f96a42c1cac598c67e624df6a2b to your computer and use it in GitHub Desktop.
MSJ Topic Labels
This file contains hidden or 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 MSJ | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Topic labels | |
// @author panosru | |
// @match https://www.macserialjunkie.com/forum/* | |
// @require http://code.jquery.com/jquery-latest.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
$(document).ready(function () { | |
// Inject CSS | |
$('head').append(`<style type="text/css"> | |
.label { | |
padding: 1px 2px; | |
border: 1px solid transparent; | |
border-radius: 4px; | |
line-height: 1.26; | |
} | |
.label-stw, | |
.label-stw-info, | |
.label-req-stw { | |
background-color: #339af0; | |
color: #083d6a; | |
} | |
.label-req { | |
background-color: #c49baf; | |
color: #1e1e1e; | |
} | |
.label-disc { | |
background-color: #758693; | |
color: #fff; | |
} | |
.label-info { | |
background-color: #20c997; | |
color: #1a5f4a; | |
} | |
.label-help { | |
background-color: #3e3e3f; | |
color: #ddd; | |
} | |
</style>`); | |
// Add labels | |
$('.topiclist').html(function (_, html) { | |
return html.replace(/(\[(STW|STW\/INFO|REQ|REQ\/STW|DISC|INFO|HELP)\])/g, function(match, p1, p2) { | |
return `<span class="label label-${p2.toLowerCase().replace('/','-')}">${p1}</span>`; | |
}); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment