Skip to content

Instantly share code, notes, and snippets.

@dvingerh
Last active February 7, 2018 11:04
Show Gist options
  • Save dvingerh/607de8d1cff4284b81c8ec7b2ff6bbf4 to your computer and use it in GitHub Desktop.
Save dvingerh/607de8d1cff4284b81c8ec7b2ff6bbf4 to your computer and use it in GitHub Desktop.
HF Profile Citation Button - Cite profiles on HackForums easily.
// ==UserScript==
// @name HF Profile Citation Button
// @namespace Because HFES's is broken.
// @version 0.3
// @description Cite profiles on HackForums easily.
// @author Cammy uid=2219785
// @match *hackforums.net/member.php?action=profile&uid=*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant GM_setClipboard
// ==/UserScript==
$( document ).ready(function() {
$(".largetext").eq(0).find("span").after('<button id="citeLink" class="button" style="margin-left: 5px;">Cite</button>');
citeLink = document.getElementById("citeLink");
citeLink.addEventListener("click", citateProfile, false);
});
function citateProfile(){
uid = window.location.href.replace(/[^0-9]/g, '');
username = $(".largetext").eq(0).find("span").last().text();
color = ($(".largetext").eq(0).find("span").last().css("color"));
color = hexc(color);
toCopy = "[url=http://www.hackforums.net/member.php?action=profile&uid=" + uid + "][color=" + color + "][b]" + username + "[/color][/b][/url]";
GM_setClipboard (toCopy);
$(this).fadeOut(150, function(){
$(this).text("Copied!");
}).fadeIn(150).delay(800).fadeOut(150, function(){
$(this).text("Cite");
}).fadeIn(150);
}
function hexc(colorval) {
var parts = colorval.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
delete(parts[0]);
for (var i = 1; i <= 3; ++i) {
parts[i] = parseInt(parts[i]).toString(16);
if (parts[i].length == 1) parts[i] = '0' + parts[i];
}
color = '#' + parts.join('');
return color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment