Created
September 20, 2017 14:17
-
-
Save anevins12/deb132fef7c5ee5f9ff1fbc83b272fed to your computer and use it in GitHub Desktop.
WordPress.org plugin repository sock-puppet flagger
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 New Plugin sock puppet flag | |
// @namespace http://tampermonkey.net/ | |
// @match https://wordpress.org/plugins/browse/* | |
// @grant none | |
// ==/UserScript== | |
var $ = jQuery, | |
ratings = $('.rating-count a'), | |
ratingsValue, | |
flagText = 'Fewer than 10 active installs'; | |
// Add CSS | |
$('head').prepend('<style>.plugin-card--flag { background: #ff6969 !important }</style>'); | |
// Remove screen reader text to help get the rating value | |
ratings.children().remove(); | |
ratings.each(function() { | |
var rating = $(this), | |
value = rating.text(), | |
wrapper = rating.parents('.plugin-card'), | |
installs = $('.active-installs', wrapper), | |
installsTrim = installs.text().trim(); | |
// If the ratings are greater than 3 & under 10 installs | |
if (value > 2 && flagText === installsTrim) { | |
// Flag the review | |
wrapper.addClass('plugin-card--flag'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment