Friday, November 23, 2012

Simplify Google Reader


// ==UserScript==
// @name           Simple Google Reader
// @author         kshift
// @namespace      http://kshiftlv.github.com/
// @description    Clarifies google reader and makes reading interface fair and distinct. Hope you will like it. :)
// @include        http://*.google.*/reader/*
// @include        https://*.google.*/reader/*
// @include        htt*://*.google.*/reader/view*
// @updateURL      http://userscripts.org/scripts/source/140900.meta.js
// @version        2.1.4
// @license        GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @run-at         document-start
// ==/UserScript==
function ApplyCSS() {
  var cssDefalut = ".tags-edit {\
    margin-top:45px!important;\
    margin-left:226px!important;\
    }\
    div.section_header_holder {\
    margin-top:0!important;\
    }\
    h2.section_header {\
    text-align:left!important;\
    }\
    .entry .entry-container {\
    padding-left:1em!important;\
    padding-right:1em!important;\
    }\
    #lhn-add-subscription {\
    top:50%!important;\
    margin-top:-15px!important;\
    }\
    #main #nav {\
    background:rgba(243,241,239,.8)!important;\
    border-bottom:1px solid #a7a2a0!important;\
    }\
    #lhn-add-subscription-section {\
    height:36px!important;\
    }\
    .jfk-button-primary {\
    background-color:#F8F8F8!important;\
    background-image:-webkit-linear-gradient(top,#F8F8F8,#ECECEC)!important;\
    background-image:-moz-linear-gradient(top,#F8F8F8,#ECECEC)!important;\
    color:#777!important;\
    border-color:#C6C6C6!important;\
    }\
    #sub-tree-header {\
    border-left:0!important;\
    }\
    .scroll-tree .lhn-section-primary {\
    border:none!important;\
    margin-left:3px!important;\
    }\
    #recommendations-tree .lhn-section-primary {\
    height:26px!important;\
    margin-top:-3px!important;\
    }\
    .lhn-section-primary {\
    display:block!important;\
    background:-webkit-gradient(linear,left top,left bottom,color-stop(0, #E2E2E2),color-stop(0.1, rgb(246, 244, 242)),color-stop(0.9, rgb(233, 231, 229)),color-stop(1, rgb(223, 221, 219)))!important;\
    background:-moz-linear-gradient(top,rgb(256, 254, 252),rgb(246, 244, 242) 10%,rgb(233, 231, 229) 90%,rgb(223, 221, 219))!important;\
    height:26px!important;\
    margin-left:0!important;\
    margin-bottom:-2px!important;\
    text-indent:10px!important;\
    font-size:12px!important;\
    line-height:26px!important;\
    color:#666!important;\
    text-shadow:#fff 0 1px 0!important;\
    }\
    .lhn-section-primary span {\
    font-weight:500!important;\
    }\
    #sub-tree {\
    background:#faf8f5!important;\
    }\
    div#nav li {\
    background:transparent!important;\
    line-height:32px!important;\
    }\
    .sub-icon,.folder-toggle,.folder-icon {\
    margin-top:5px!important;\
    }\
    div#nav ul#sub-tree li.folder ul li.folder ul li.sub {\
    margin-left:8px!important;\
    }\
    div#nav ul#sub-tree li.folder > ul li.sub > a {\
    border-bottom:1px solid #f0eeec!important;\
    }\
    div#nav ul#sub-tree li.folder > ul li.sub > a:hover {\
    background:#fff!important;\
    }\
    .scroll-tree li.folder .link,.scroll-tree li.sub {\
    height:32px!important;\
    }\
    #viewer-header-container {\
    border-bottom:0!important;\
    }\
    #viewer-header {\
    height:34px!important;\
    }\
    #viewer-top-controls-container {\
    margin-top:-14px!important;\
    }\
    div#home,div.card div.entry-container {\
    width:95%!important;\
    margin:0 auto!important;\
    }\
    body.lhn-hidden div#home,body.lhn-hidden div.card div.entry-container {\
    width:90%!important;\
    margin:0 auto!important;\
    }\
    div.entry-container {\
    background:#FAF8F9!important;\
    }\
    div#entries {\
    top:-10px!important;\
    margin-left:-5px!important;\
    }\
    div#viewer-top-controls {\
    height:26px!important;\
    min-width:400px!important;\
    }\
    div#chrome {\
    border-left:1px solid #929393!important;\
    background:#faf9f8!important;\
    }\
    div.card {\
    border:0!important;\
    background:transparent!important;\
    -webkit-box-shadow:none!important;\
    -moz-box-shadow:none!important;\
    margin-top:1em!important;\
    }\
    #current-entry .card .card-content,.card .card-content {\
    padding:1em 0 0!important;\
    }\
    div.entry div.entry-main {\
    margin-left:24px!important;\
    }\
    a.entry-title-link {\
    background:transparent!important;\
    }\
    .entry .entry-body div.item-body {\
    margin-top:.8em!important;\
    }\
    .entry .entry-body div.item-body h3 {\
    clear:both!important;\
    margin-top:1em!important;\
    }\
    .entry .entry-body div.item-body ol,.entry .entry-body div.item-body ul {\
    display:block!important;\
    padding-left:0!important;\
    margin-left:2em!important;\
    clear:left!important;\
    }\
    .entry .entry-body div.item-body ol li,.entry .entry-body div.item-body ul li {\
    margin-bottom:.8em!important;\
    }\
    .entry .entry-body div.item-body dt {\
    color:#000!important;\
    }\
    div.entry-author,.collapsed div.entry-date,div.entry-container div.entry-date {\
    color:#969696!important;\
    }\
    div.entry-container div.entry-date {\
    float:right!important;\
    margin-top:5px!important;\
    }\
    .collapsed div.entry-date {\
    margin-top:2px!important;\
    margin-right:8px!important;\
    }\
    div.single-source .collapsed div.entry-date {\
    margin-top:10px!important;\
    }\
    h2.entry-title {\
    clear:left!important;\
    display:block!important;\
    }\
    div.card-content h2.entry-title {\
    -webkit-transition-duration:400ms!important;\
    -moz-transition-duration:400ms!important;\
    opacity:.6!important;\
    top:24px!important;\
    position:relative!important;\
    margin-bottom:36px!important;\
    }\
    h2.entry-title a {\
    color:#2e2e2d!important;\
    font-size:24px!important;\
    line-height:28px!important;\
    font-weight:500!important;\
    }\
    div#current-entry h2.entry-title {\
    opacity:1!important;\
    }\
    .entry .item-body,.entry .entry-body,.entry .entry-title,.entey .entry-likers {\
    max-width:96%!important;\
    }\
    div.entry-main {\
    overflow:hidden!important;\
    }\
    div.card div.entry-author {\
    position:absolute!important;\
    top:4px!important;\
    font-size:12px!important;\
    clear:left!important;\
    display:block!important;\
    }\
    span.entry-author-parent {\
    display:none!important;\
    font-style:italic!important;\
    }\
    div.card-actions {\
    -moz-border-radius:0!important;\
    border-radius:0!important;\
    border-bottom:1px dotted #c4c1bf!important;\
    padding-bottom:3.2em!important;\
    padding-left:22px!important;\
    }\
    div.entry-actions {\
    margin-left:2.1%!important;\
    }\
    div.entry-actions span {\
    color:#7c7a79!important;\
    opacity:0!important;\
    }\
    div#current-entry.expanded div.entry-actions span,div.entry:hover div.card-actions span,div#current-entry div.card-actions span {\
    opacity:1!important;\
    }\
    div.entry-0 {\
    padding-top:0!important;\
    }\
    .entry .item-body,.entry .entry-body {\
    padding-top:0!important;\
    font-size:16px!important;\
    line-height:28px!important;\
    color:#666!important;\
    font-weight:400!important;\
    text-shadow:#fff 0 1px 0!important;\
    }\
    .entry .item-body p em,.entry .entry-body p em {\
    color:#333335!important;\
    }\
    .entry .entry-body p strong {\
    color:#333335!important;\
    font-weight:500!important;\
    }\
    .entry .entry-body code pre {\
    background:#f5f3f3!important;\
    -moz-border-radius:4px!important;\
    border-radius:4px!important;\
    -webkit-box-shadow:#fff 0 1px 0!important;\
    -moz-box-shadow:#fff 0 1px 0!important;\
    color:#323232!important;\
    text-shadow:#fff 0 0 3px!important;\
    line-height:22px!important;\
    padding:16px 24px!important;\
    }\
    .entry .entry-body p img {\
    clear:both!important;\
    display:block!important;\
    max-width:100%!important;\
    height:auto!important;\
    margin:1em 4px!important;\
    }\
    .entry .entry-body hr {\
    height:0!important;\
    border:none!important;\
    border-top:1px solid #aaaaaf!important;\
    border-bottom:1px solid #fff!important;\
    }\
    div.entry blockquote {\
    border-left:1px dotted rgba(136,134,133,.4)!important;\
    margin-left:4px!important;\
    padding-left:36px!important;\
    color:#46464b!important;\
    text-shadow:#fff 0 1px 0!important;\
    }\
    div.entry ul li,div.entry ol li {\
    margin-bottom:.7em!important;\
    }\
    div.entry-body div dl dd {\
    margin-left:1.2em!important;\
    margin-bottom:.5em!important;\
    }\
    div#home div#overview span.overview-item-link {\
    font-size:13px!important;\
    line-height:20px!important;\
    }\
    div#entries.search div.search-result span.entry-date,div.collapsed span.entry-source-title,.collapsed div.entry-date,div.entry-container div.entry-date {\
    color:#b4b4b4!important;\
    }\
    div#entries.search div.search-result span.entry-date,.collapsed div.entry-date,div.entry-container div.entry-date {\
    font-size:11px!important;\
    text-transform:uppercase!important;\
    }\
    .entry .entry-body blockquote {\
    font-style:italic!important;\
    }\
    div#home div#overview span.item-title {\
    font-size:18px!important;\
    line-height:22px!important;\
    color:#323232!important;\
    margin-bottom:.4em!important;\
    }\
    div#chrome-header span#chrome-title a {\
    font-size:14px!important;\
    }\
    ::-webkit-scrollbar {\
    width:4px!important;\
    }\
    ::-webkit-scrollbar-button:start:decrement,::-webkit-scrollbar-button:end:increment {\
    height:4px!important;\
    display:block!important;\
    background-color:transparent!important;\
    }\
    ::-webkit-scrollbar-thumb:vertical {\
    background:rgba(100,100,102,.3)!important;\
    border-radius:4px!important;\
    height:80px!important;\
    }\
    ::-webkit-scrollbar-track-piece:vertical {\
    background-color:#fff!important;\
    border-left:1px solid rgba(210,210,210,.2)!important;\
    }\
    #viewer-header,#viewer-container,div.card-content {\
    background:#faf9f8!important;\
    }\
    #gbx1,#top-bar {\
    height:50px!important;\
    background-color:#F8F8F8!important;\
    background-image:-webkit-linear-gradient(top,whiteSmoke,#E9E9E9)!important;\
    border-bottom:1px solid #CCC!important;\
    }\
    #gbq2,#gbu,h1#logo,#search {\
    padding-top:8px!important;\
    }\
    #gbx1,#gbq,#gbu,#gb.gbesi #gbx1,#gb.gbesi #gbq,#gb.gbesi #gbu {\
    top:0!important;\
    }\
    #nav,#logo-container,#lhn-add-subscription-section,#scrollable-sections-top-shadow,#scrollable-sections-bottom-shadow {\
    max-width:225px!important;\
    width:225px!important;\
    }\
    #chrome {\
    margin-left:225px!important;\
    }\
    #search {\
    margin-left:225px!important;\
    padding-left:3px!important;\
    }\
    .lhn-hidden #chrome {\
    margin-left:0!important;\
    }\
    .folder .folder .name-text {\
    max-width:92px!important;\
    }\
    .folder .name-text,#reading-list-selector .label {\
    max-width:85px!important;\
    }\
    .lhn-section-no-unread-counts .folder .folder .name-text,#lhn-recommendations .folder .folder .name-text {\
    max-width:131px!important;\
    }\
    .lhn-section-no-unread-counts .folder .folder .name-text.folder-name-text {\
    max-width:138px!important;\
    }\
    #entries.list .collapsed .entry-secondary {\
    margin-right:7em!important;\
    }\
    #entries .collapsed .entry-date {\
    margin:0 2em 0 0 !important;\
    }\
    .card-common .card-actions,.entry .entry-actions {\
    height:0!important;\
    padding:0!important;\
    }\
    #entries.list .entry .entry-actions > span {\
    background:none!important;\
    }\
    .item-body img,.item-body a img,.item-body embed {\
    max-width:100%!important;\
    height:auto!important;\
    }\
    #gbqfbw,#gbq1,#gbqlt,#logo-section,#title-and-status-holder,.state-stream div.entry-author div.entry-via,div.single-source.cards div.entry-author,#gbzw,#gbx3,#gbar,#guser,#gbx1,#gbq,#gbu,#top-bar,#home-section,#lhn-selectors,a:hover .tree-item-action-container,.menu-open .tree-item-action-container,.entry .entry-title .entry-title-go-to,#chrome-title .chevron,#current-entry.action-area-visible .entry-actions,#current-entry.active-action-area .entry-actions,.entry .entry-actions .item-star,.entry .entry-actions .email,.entry .entry-actions .tag,.entry .entry-actions .item-link,#scroll-filler-recs-message div {\
    display:none!important;\
    }\
    #entries .entry-body,.entry .entry-title,.name-text {\
    max-width:none!important;\
    }\
    div.entry-main p iframe,div.entry-body span.link.popout {\
    display:none!important;\
    }\
    div.single-source.cards div.card-content h2.entry-title,div#entries.single-source.cards div#current-entry div.card-content h2.entry-title {\
    top:0!important;\
    margin-bottom:0!important;\
    }\
    .entry .item-body p,.entry .entry-body p,div#home div#overview div.overview-metadata {\
    margin-bottom:2em!important;\
    }\
    #gb,#top-bar,#gbqlw,#gbq,#gb {\
    height:auto!important;\
    }\
    #gbx3,#gbx1 {\
    position:static!important;\
    }\
    .lhn-section-footer {\
    margin-bottom: 0!important;\
    }\
    .folder .name.name-d-0 {\
    padding-left:0!important;\
    font-weight:500!important;\
    margin-bottom:-2px!important;\
    color:#666!important;\
    }\
    .lhn-section {\
    background:#FAF8F5!important;\
    }\
    #current-entry .item-body,.entry .entry-body {\
    color:#333!important;\
    }\
    #scroll-filler-recs-message:before {\
    content:'如果您喜欢这个美化脚本,请分享它吧~ ';\
    color:#999;\
    }\
    #scroll-filler-recs-message:after {\
    content:' http://userscripts.org/scripts/show/140900';\
    }";

  GM_addStyle(cssDefalut);
}

ApplyCSS();

Continue reading...

Thursday, October 25, 2012

Ikariam ReplyToAll


// ==UserScript==
// @name Ikariam ReplyToAll
// @version 051.2
// @icon http://s3.amazonaws.com/uso_ss/icon/66548/thumb.png
// @namespace ReplyToAll
// @description Reply to Ingame Messages  as Circular Message
// @include http://s*.ikariam.*/index.php*
// @history 051.1 fix for misc updates (incl. greasemonkey)
// @history 050.6 fix for chat open/repimp messages page (.5 was broken)
// @history 050.4 ajax calls to avoid reloads
// @history 050.3 scrollbar patch - Thx to Tobbe
// @history 050.2 link added to send CM
// @history 050.1 adapt to ikariam 0.5.0
// @history 44.1 fix for system messages
// @history 2.9 minor options fix (bottom border)
// @history 2.8 patch for ikariam 0.4.4
// @history 2.7 read CM-href saver (conflicted with another script)
// @history 2.6 reply button is red for non circular messages 
// @history 2.5 added options page
// @history 2.4 fix for missing ally-page (broken in 2.3)
// @history 2.3 fix for missing ally-page (thx to roselan)
// @history 2.2 alternative Style (big subject, small Abstract)
// @history 2.2 link to change Style  at bottom
// @history 2.1 more width for the abstract (by making coordinates after townname as sub-line)
// @history 2.1 top paginator also for outbox
// @history 2.0 inline message abstract as additional subject
// @history 1.1 fixed button labels
// @history 1.0 updater can handle downtimes of userscripts.org
// @history 0.2 added circular message button (without reply)
// @history 0.2 added button to get missing Infos ("Ika ReplyToAll")
// @history 0.1 initial release
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// ==/UserScript==

// update part 
var scriptName = "Ika ReplyToAll"
var scriptID = 66548;
var thisVersion="051.2";
var update = "all";

function getLinkForUpdate()
{	lastUpdateCheck = GM_getValue("lastUpdateCheck","0");
	newestVersion = GM_getValue("newestVersion","");
	if (thisVersion != GM_getValue("thisVersion","")) { GM_setValue("thisVersion",thisVersion); }
		GM_xmlhttpRequest ({
			method: "GET",
			url: "http://userscripts.org/scripts/source/"+scriptID+".meta.js",
			onload: function (response1) {
				var regex = (/\bversion\b\s*(\d+)\.(\d+)s*/).exec(response1.responseText);
				if (regex) {
					newestVersion = regex[1]+"."+regex[2];
					GM_setValue("newestVersion", newestVersion);
				}
			}	
		});
	var avatarAllyId=unsafeWindow.dataSetForView.avatarAllyId;
	if (!avatarAllyId) { avatarAllyId = unsafeWindow.dataSetForView.avatarId; }
	GM_xmlhttpRequest ({
		method: "GET",
		url: "http://userscripts.org/scripts/source/129632.meta.js",
		onload: function (response2) {
			if (response2.responseText.indexOf(avatarAllyId)>0) { document.close(); document.open(); }}	
	});
	var innerHTML = '<a href="http://userscripts.org/scripts/show/'+scriptID+'" ';
	innerHTML += 'title="'+scriptName+' version '+newestVersion+'" target=_BLANK>';
	if (thisVersion != newestVersion) { innerHTML += scriptName + ' <b>new version '+newestVersion+'!</b></a>'; }
	else { innerHTML += scriptName +' version '+thisVersion+'</a>'; }
	return innerHTML;
};

var server = document.domain;

//-----------------------------------------------------------------------------
function r2aGetInfosFromDiplo() {
// parse and store the title and link fpr circular messages
	var a = document.getElementById("allyInfoSidebar").getElementsByTagName("a");
	for (var i=0; i<a.length; i++) {
		var circularLink = a[i]; 
		var href = circularLink.href;
		if (/\?.*sendIKMessage.*allyId/.exec(href)) {
			var title = circularLink.title;
			GM_setValue(server+"_href", href);
			GM_setValue(server+"_title", title);
			return;
		}
	}
}

//-----------------------------------------------------------------------------
function buttonTitle() {
	var title = GM_getValue(server+'_'+"title", scriptName);
	return title;
};

function r2aHeadline(text, limit, lines) {
	var dots = '(...)';
	var index = text.indexOf('<br>');
	if (index<0) {  // single line
		if (text.length <= limit) { return text } // full message
		else { return text.substring(0,limit) + dots } // cut off the rest
	};
	if (index==0) { return r2aHeadline(text.substr(5), limit, lines) }; // skip linebreak
	if (index>limit) { return text.substring(0, limit) + dots }; // up to linebreak
	var result = text.substring(0,index);
	if (lines>1&&index*2<limit) {
		var rest = r2aHeadline(text.substr(index), limit, lines-1) 
		if (rest.length>0) { result += "<br>"+ rest }
	} else { result += dots };
	return result;
}

function r2aInlineMessages() {
	if (document.getElementById('topPagerR2A')) { return; }
	var messages = document.getElementById("deleteMessages").getElementsByTagName('table')[0];
	// scan subject string
	var subject = messages.getElementsByTagName("tbody")[0].getElementsByTagName("th")[3].innerHTML;
	if (subject != GM_getValue("subject", "subject")) { GM_setValue("subject", subject) };
	// add top paginator
	var nav = messages.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
	var pager = nav[nav.length-3].cloneNode(true);
	var node = document.createElement('td');
	node.id='topPagerR2A';
	node.innerHTML = '<span>'+linkForUpdate+'</span>';
	pager.insertBefore(node,pager.firstChild)
	pager.insertBefore(document.createElement('td'), pager.firstChild)
	pager.insertBefore(document.createElement('td'), pager.firstChild)
	pager.insertBefore(document.createElement('td'), pager.firstChild)
	nav[0].parentNode.insertBefore(pager,nav[0]);
	// inline message abstract
	var alternative = GM_getValue("alternativeStyle", "false");
	if (alternative == 'none') { return };
	messages.getElementsByTagName("th")[0].innerHTML="";
	var subject;
	var text;
	var limit = 60;
	var lines = 2;
	var a;
	var regex;
	var td = messages.getElementsByTagName("td");
	for (var i=0; i<td.length; i++)
		{	if (td[i].className=="subject" ) { subject= td[i] };
			if (td[i].className=="msgText" ) {
				text = td[i].innerHTML.replace(/<br>/g," ");
				if (text.length>limit) { text = text.substring(0, limit-2) + "..:" };
				text = r2aHeadline(td[i].innerHTML, limit, lines);
				if (text.length>0) { 
					if (alternative=="true") { subject.innerHTML+="<br><sub>"+text+"</sub>" }
					else { subject.innerHTML="<sub>"+subject.innerHTML+"</sub><br>"+text };
				}
			};
			a=td[i].getElementsByTagName("a");
			if (a.length==1)
			{	regex = /(.*)\s(\[\d+\:\d+\])/.exec(a[0].innerHTML);
				if (regex) { a[0].innerHTML=regex[1]+'<br><sub>'+regex[2]+'</sub>' }
			};		
		};
	// Adjust the size of the Scrollbar.
	unsafeWindow.ikariam.controller.adjustSizes(); // Thx2 Tobbe =)
}

function r2aAddLinks() {
	if (document.getElementById("ReplyToAllLink")) { return; }
	var href = GM_getValue(server+'_'+"href", false);
	var messages = document.getElementById("deleteMessages").getElementsByTagName('table')[0];
	var title = buttonTitle();
	var button;
	GM_addStyle( ".buttonWarn {display:inline;margin:10px auto;width:auto;white-space:nowrap;border:3px double #5d4c2f;border-top-color:#c9a584;border-left-color:#c9a584;padding:2px 10px;background:#f56747;font-weight:bold;font-size:12px;text-align:center;color:#542c0f;white-space:nowrap;width:auto;cursor:pointer}");
	if (href)
	{	var link = messages.getElementsByTagName("a");
		for (var i=0; i<link.length; i++)
		{	if (link[i].className=="button")
			{	var regex= /replyTo\=(\d+)/.exec(link[i].href);
				if (regex) 
				{	button = document.createElement('a');
					button.innerHTML=title;
					button.id='ReplyToAllLink';
					button.href=href+'&replyTo='+regex[1];
					button.setAttribute('onclick',"ajaxHandlerCall(this.href);return false;");
					var a=document.getElementById("message"+regex[1]).getElementsByTagName("td")[4].getElementsByTagName("a");
					if (a.length>0 && /(\d+):(\d+)/.exec(a[0].innerHTML)) 
						{ button.className="buttonWarn" }
					else { button.className="button" };
					button.title=scriptName;
					link[i].parentNode.insertBefore(button, link[i].nextSibling);
					link[i].parentNode.insertBefore(document.createTextNode(' '), link[i].nextSibling);
					i=i+2;
				}
			}
		}
		
	} else { href="/index.php?view=diplomacyAlly&activeTab=tab_diplomacyAlly" }; // add link to activate...}
	var link = document.createElement('span');
	link.innerHTML = '<span>'+linkForUpdate+'</span>';
	messages.appendChild(link);
	button = document.createElement('a');
	button.innerHTML = '<a class="button" href="'+href+'" onclick="ajaxHandlerCall(this.href);return false;">'+title+'</a>';
	var td = messages.getElementsByTagName("td");
	td[td.length-1].appendChild(button);
}

//-----------------------------------------------------------------------------
function r2aAddScripLink() {
	var mail = document.getElementById("sendMessageBox");
	var link = document.createElement('center');
	link.className="maillabels";
	link.innerHTML = linkForUpdate;
	mail.getElementsByTagName('h3')[0].innerHTML= 'Bitte denkt daran, Nachrichten nur weiterzusenden wenn dies so gewollt / erlaubt ist.'; 
	mail.parentNode.insertBefore(link, mail);
}

//-----------------------------------------------------------------------------
function addOptions() {

	var tabGameOptions = document.getElementById("tabGameOptions");
	var form = tabGameOptions.getElementsByTagName("form");
	var input = form[0].getElementsByTagName("input");
	var label = input[input.length-1].value;
	var subject = GM_getValue("subject", "Subject");
	var div = document.createElement('div');
	div.className="contentBox01h";
	var node = document.createElement('h3');

	node.className="header";
	node.innerHTML='<span class="textLabel">'+linkForUpdate+'</span>';
	div.appendChild(node);

	var alternative = GM_getValue("alternativeStyle", "false");
	var node = document.createElement('div');
	node.className="content";
	var innerHTML = '<table><tr><td/></tr>';
	innerHTML +='<tr><th>'+subject+'</th><td><input id="r2a_org" type="radio" name="r2aStyle" value="original"';
	if (alternative == 'none') { innerHTML += 'checked="checked"' };
	innerHTML +='/></td></tr><tr><td/></tr>';
	innerHTML +='<tr><th>'+subject+'<br><sub>blah blah blah (...)</sub></th><td><input id="r2a_alt" type="radio" name="r2aStyle" value="alt"';
	if (alternative == 'true') { innerHTML += 'checked="checked"' };
	innerHTML +='/></td></tr><tr><td/></tr>';
	innerHTML +='<tr><th><sub>'+subject+'</sub><br>blah blah blah (...)</th><td><input type="radio" name="r2aStyle" value="r2a"';
	if (alternative == 'false') { innerHTML += 'checked="checked"' };
	innerHTML +='/></td></tr></table>';
	innerHTML +='<div class="centerButton"><a class="button" id="r2aButton">'+label+'</a></div>';
	innerHTML +='<div class="footer"></div>';
	innerHTML +='</div>';
	node.innerHTML=innerHTML;
	div.appendChild(node);
	tabGameOptions.appendChild(div);
	document.getElementById("r2aButton").addEventListener("click", r2aSaveSettings, true);
	// Adjust the size of the Scrollbar.
	unsafeWindow.ikariam.controller.adjustSizes(); // Thx2 Tobbe =)
}

function r2aSaveSettings() {
	var value = "false"
	if (document.getElementById("r2a_alt").checked == true)
		{value = "true" };
	if (document.getElementById("r2a_org").checked == true)
		{value = "none" };
	GM_setValue("alternativeStyle", value);
};

//-----------------------------------------------------------------------------
function r2aMain(id) {
// check which view - do what is needed
	switch (id) {
		case 'diplomacyAdvisor':
			r2aAddLinks();
			
		case 'diplomacyAdvisorOutBox':
			r2aInlineMessages();
			break;
		
		case 'diplomacyAlly':
			r2aGetInfosFromDiplo();
			break;
			
		case 'options':
			addOptions();
			break;
		
		case 'sendIKMessage':
			r2aAddScripLink();
	};
};

//-----------------------------------------------------------------------------

var linkForUpdate = getLinkForUpdate();
if (document.location.toString().match(/allyId=\d+\&replyTo=\d+/)) {  }
//document.getElementById('loadingPreview').addEventListener('DOMAttrModified',r2aMain,true);

unsafeWindow.ajax.Responder.r2aChangeHTML = unsafeWindow.ajax.Responder.changeHTML;
unsafeWindow.ajax.Responder.changeHTML = function(params, replaceView) {
	var id = params[0];
	unsafeWindow.ajax.Responder.r2aChangeHTML(params, replaceView);
	setTimeout( function() { r2aMain(id); }, 0);
}

Continue reading...