GOTA Improvements

Various improvements to Game of Thrones: Ascent

ของเมื่อวันที่ 20-05-2014 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @name        GOTA Improvements
// @description Various improvements to Game of Thrones: Ascent
// @namespace   https://greasyfork.dpdns.org/users/1665-nolana
// @include     http://gota.disruptorbeam.com/
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version     2
// @grant       none
// ==/UserScript==

this.$ = this.jQuery = jQuery.noConflict(true);

// $('div.locked').remove();
$(window).bind("load", function() {
   init();                        
});


function init() {
    $('#page-wrap').css('max-width',$(window).width()+'px');
    $('#holdings_container').width($(window).width()-10);
    // remove locked buildings
   // $(document).on('click','#navlink-buildings',function (e) {
   //   $('#building_items div.locked').remove();
   //});
   fixChat();
   observeChat();     
}

 
function fixChat() {
    var chatWidth = $(window).width()/3;
    addGlobalStyle(".gamechat{bottom:auto;float:none;height:auto;left:auto;right:188px;margin-left:2px;margin-top:8px;padding:1px 10px 15px;position:absolute;top:3px;width:" + chatWidth +"px;"+
                   "background:url(http://disruptorbeamcdn-01.insnw.net/images/pvp/actionbg.png?t=e2e9110ff577) repeat-x scroll 0 0 #000;border:1px solid #444;border-radius:12px;color:#FFF;font-size:16px;text-align:left;z-index:3}");
    addGlobalStyle("b {font-weight:bold}");
    addGlobalStyle("sub {font-size:11px;color:grey}");
    addGlobalStyle(".gamechat .chatscroll p { width: " + (chatWidth - 60) + "px;margin-bottom: 2px;font-size: 14px;");
    addGlobalStyle("div.locked { display:none; }");
   $('#combatlog').width(chatWidth - 10);
    
    $('#combatlog .jspPane p.pchat').each(function () {
        fixChatLine($(this));
    });
}

function observeChat() {
    var target = $('#combatlog .jspPane')[0];
    // Create an observer instance
    var observer = new MutationObserver(function( mutations ) {
       mutations.forEach(function( mutation ) {
       var newNodes = mutation.addedNodes; // DOM NodeList
       if (newNodes !== null) { // If there are new nodes added
    	var $nodes = $(newNodes); // jQuery set
    	$nodes.each(function() {
    		var $node = $(this);
    		if ($node.hasClass( "pactivity" )) {
                console.log('act:'+$node.text());
                // TODO, fix activity line
    		} else if ($node.hasClass("pchat")) {
                console.log('chat:' + $node.text());
                fixChatLine($node, new Date().toLocaleString());
            }
    	});
       }
     });    
    });
    var config = { 
	   attributes: false, 
	   childList: true, 
	   characterData: false 
    };
    observer.observe(target, config);
}

function fixChatLine(p, time) {
    var text = p.text();
    var result = /([^:]+):(.*)/.exec(text);
    if (result == null) return; // already highlighted
    var author = result[1];
    var line = result[2];
   
    p.find('strong').replaceWith('<strong><b>' + author + '</b>' + line + (time ? '  <sub>' + time + '</sub>' : ''));
  
}
function addGlobalStyle(css) {
		try {
			var elmHead, elmStyle;
			elmHead = document.getElementsByTagName('head')[0];
			elmStyle = document.createElement('style');
			elmStyle.type = 'text/css';
			elmHead.appendChild(elmStyle);
			elmStyle.innerHTML = css;
		} catch (e) {
			if (!document.styleSheets.length) {
				document.createStyleSheet();
			}
			document.styleSheets[0].cssText += css;
		}
}
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元