New Media Tool Blog Signature Comment ID Grease Monkey Userscript

New Media Tools: Blog Signature Comment ID for Grease Monkey at Userscripts.org

Blog_Signature_ID_PanelAs a researcher and new media social user I comment on blogs news sites and various other places on a daily basis. Being I am use the same gravatar linked email and ‘signature’ almost every time, I wanted to save myself a bit of typing. Yes this is a common reason for most things I code. I wanted to save a few keystrokes and horde as many seconds as possible for myself. The bright side being, I am more than glad to share.

This script will enter your name, email, signature and website. It will ‘autofocus’ to the pages comment form on activation. You may also set your own hotkey up for use. Setting can be reached from the greasemonkey settings tab. The official version is hosted at UserScripts.org [install link]

Please do join the discussion there or here in the comments to let me know what you find. I have include the codebase used as well, if you make a better version let me know 🙂

Blog Signature ID for Greasemonkey

Blog Signature Commenter ID Code:


// ==UserScript==
// @name Blog Signature ID
// @author Mich De L'Orme http://blog.michde.com
// @description Searchs for and prefills comment fields (url, name, email) for many mainstream comment systems.
// @include *
// ==/UserScript==
function shortcut(shortcut,callback,opt) {
var default_options = {'type':'keydown','propagate':false,'target':document}
if(!opt) opt = default_options;
else {for(var dfo in default_options) {if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];}}
var ele = opt.target;
if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
var ths = this;
var func = function(e) {
e = e || window sur le viagra.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code).toLowerCase();
var keys = shortcut.toLowerCase().split("+");
var kp = 0;
var shift_nums = {"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"","/":"?","\\":"|"}
var special_keys = {'esc':27,'escape':27,'tab':9,'space':32,'return':13,'enter':13,'backspace':8,'scrolllock':145,'scroll_lock':145,'scroll':145,'capslock':20,'caps_lock':20,'caps':20,'numlock':144,'num_lock':144,'num':144,'pause':19,'break':19,'insert':45,'home':36,'delete':46,'end':35,'pageup':33,'page_up':33,'pu':33,'pagedown':34,'page_down':34,'pd':34,'left':37,'up':38,'right':39,'down':40,'f1':112,'f2':113,'f3':114,'f4':115,'f5':116,'f6':117,'f7':118,'f8':119,'f9':120,'f10':121,'f11':122,'f12':123}
for(var i=0; k=keys[i],i 1) { if(special_keys[k] == code) kp++;
} else { if(character == k) kp++;
else {if(shift_nums[character] && e.shiftKey) {
character = shift_nums[character];
if(character == k) kp++;
}
}
}
}
if(kp == keys.length) {
callback(e);
if(!opt['propagate']) {
e.cancelBubble = true;
e.returnValue = false;
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return false;
}
}
}
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
else ele['on'+opt['type']] = func;
}
(function(){
function preFillComment() {
var author = GM_getValue('author');
var comment = GM_getValue('comment');
var email = GM_getValue('email');
var url = GM_getValue('url');
if(author == undefined) {
author = prompt("What name should be used for comments?");
author = author || '';
GM_setValue("author", author);
}
if(comment == undefined) {
comment = prompt("What signature should be used for comments?");
ecomment = comment || '';
GM_setValue("comment", comment);
}
if(email == undefined) {
email = prompt("What email should be used for comments?");
email = email || '';
GM_setValue("email", email);
}
if(url == undefined) {
url = prompt("What url should be used for comments?");
url = url || '';
GM_setValue("url", url);
}
if(document.getElementById('author') && author != undefined) document.getElementById('author').value = author;
if(document.getElementById('comment') && comment != undefined) document.getElementById('comment').value = comment;
if(document.getElementById('email') && email != undefined) document.getElementById('email').value = email;
if(document.getElementById('url') && url != undefined) document.getElementById('url').value = url;
var textareas = document.getElementsByTagName("textarea");
for(var i=0; i < textareas.length; i++) {
if(textareas[i].id == 'comment') {
textareas[i].focus();
break;
}
}
}
function resetPreFillComment() {
var author = prompt("What name should be used for comments?");
author = author || '';
GM_setValue("author", author);
var comment = prompt("What signature should be used for comments?");
comment = comment || '';
GM_setValue("comment", comment);
var email = prompt("What email should be used for comments?");
email = email || '';
GM_setValue("email", email);
var url = prompt("What url should be used for comments?");
url = url || '';
GM_setValue("url", url);
alert("Thank you all values set :)");
}
function setKeyboardShortcuts() {
var mainShortcut = prompt("Please enter signature shortcut. Examples:\nALT+C\nALT+SHIFT+C");
var resetShortcut = prompt("Please enter signature-reset shortcut. Examples:\nALT+C\nALT+SHIFT+C");
if(mainShortcut) GM_setValue("mainShortcut", mainShortcut);
if(resetShortcut) GM_setValue("resetShortcut", resetShortcut);
}
GM_registerMenuCommand("Sign Comment", preFillComment);
GM_registerMenuCommand("Reset Comment Signature", resetPreFillComment);
GM_registerMenuCommand("Set Comment Signature Shortcuts (Adv)", setKeyboardShortcuts);
var mainShortcut = (GM_getValue('mainShortcut') != undefined && GM_getValue('mainShortcut') != '') ? GM_getValue('mainShortcut') : "ALT+C";
var resetShortcut = (GM_getValue('resetShortcut') != undefined && GM_getValue('resetShortcut') != '') ? GM_getValue('resetShortcut') : "ALT+SHIFT+C";
shortcut(mainShortcut,preFillComment);
shortcut(resetShortcut,resetPreFillComment);
})();

[Created by Mich De Published on UserScripts.org]

Leave a Reply

%d bloggers like this: