Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WordPress.com Forums Userscript 0.2
// ==UserScript==
// @name WordPress.com Forums Userscript 0.2.2
// @namespace http://tampermonkey.net/
// @version 0.2.2
// @description Searches posts for tags and adds icons to main post page. Removes duplicate posts. Opens links in new tab.
// @author Terry Brownell aka joerepublic
// @include https://en.forums.wordpress.com/
// @include https://en.forums.wordpress.com/page/*
// @include https://en.forums.wordpress.com/view/no-replies*
// @include https://en.forums.wordpress.com/view/no-replies/page/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function() {
'use strict';
var hideduplicates = true;
var targetblank = true;
var tagarray = {'duplicate': '☠', 'modlook': '♛', 'delete': '✄', 'domain': '🌐', 'billing': '$', 'css': 'CSS'};
var theid;
$(document).ready(function() {
if(targetblank){
$("a").attr("target","_blank");
}
var base = "setnew";
var num = 0;
$('.topictitle ').each(function(data) {
var html = $(this).html();
var href = html.match(/\bhttps?:\/\/\S+/gi);
num++;
var id = base+num;
var theid ='#'+id;
$(this).attr('id', id);
$.get(href, function(data){
var txt = $(data).find('.tags-list').text().toLowerCase();
for (var key in tagarray){
if (~txt.indexOf(key)){
$(theid).append("<span style='color: gray; margin-left: 25px;'>"+tagarray[key]+"</span>");
}
}
if(~txt.indexOf('duplicate') && hideduplicates === true ){
$(theid).parent().delay(1000).fadeOut( 1000, function() {});
}
});
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment