Skip to content

Instantly share code, notes, and snippets.

@anevins12
Created September 20, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anevins12/deb132fef7c5ee5f9ff1fbc83b272fed to your computer and use it in GitHub Desktop.
Save anevins12/deb132fef7c5ee5f9ff1fbc83b272fed to your computer and use it in GitHub Desktop.
WordPress.org plugin repository sock-puppet flagger
// ==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