inthemix hax for extreme postlords

combines old swagometer & cat scripts. RIP userscripts.org

目前為 2014-08-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name        inthemix hax for extreme postlords
// @namespace   https://greasyfork.org/users/4295-rwslol
// @description combines old swagometer & cat scripts. RIP userscripts.org
// @include     http://www.inthemix.com.au/forum/showthread.php?*
// @include     http://www.inthemix.com.au/forum/showpost.php?*
// @require     http://code.jquery.com/jquery-1.11.1.min.js
// @version     2.0.1
// @grant       none
// ==/UserScript==

// one uses jquery, the other doesn't. call the cops idgaf
// might combine them more elegantly later

// swagometer
dls = document.getElementsByTagName('dl');

for (i = 0; i < dls.length; i++) {
	// lol just do everything with innerHTML nobody will care
	m = dls[i].innerHTML.match(/<\/span>[\r\n 	]*([0-9,]+)[\r\n 	]*<\/div>/i);
	likes = parseInt(m[1].replace(',', ''));
	
	m = dls[i].innerHTML.match(/info-second-amt">[\r\n 	]*([0-9,]+)[\r\n 	]*<\/dd>/i);
	posts = parseInt(m[1].replace(',', ''));
	
	swag = parseInt(likes / posts * 100000) / 1000;
	
	dls[i].innerHTML += '<dt style="border: 0; border-top: 1px solid #ccc">Swag</dt><dd style="border: 0; border-top: 1px solid #ccc; width: 100px">' + swag + '%</dd>';
}

// cats
$(function() {
	var catHtml = function() {
		$(this).html('<img src="http://thecatapi.com/api/images/get?category=sunglasses#' + Math.random() + '">');
	};
	
	$('.post-content a[href="profile.php?do=editlist"]').closest('.post-content').each(catHtml);
});