Last active
July 11, 2017 16:12
-
-
Save ShinyRockets/46559ed126b3480440f750482f73d962 to your computer and use it in GitHub Desktop.
WordPress.com Forums Userscript 0.2
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.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