public

Small improvements to the Ingress Chat at ingress.com/intel. 1. Better distinction between public/faction chat. Prevents accidentally posting to public. 2. Switch to faction chat by default. 3. Ability to hide automated messages (will consume a LOT of CPU though, so beware). 4. Scrolling up in chat issmoother (less “Loading…”) 5. Bits and pieces.

  • Download Gist
ingress_intel_chat_improvements.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
// ==UserScript==
// @name ingress.com/intel chat improvements
// @description Small improvements to the Ingress Chat at ingress.com/intel. 1. Better distinction between public/faction chat. Prevents accidentally posting to public. 2. Switch to faction chat by default. 3. Ability to hide automated messages (will consume a LOT of CPU though, so beware). 4. Scrolling up in chat issmoother (less “Loading…”) 5. Bits and pieces.
// @namespace https://gist.github.com/4415985
// @updateURL https://gist.github.com/raw/4415985/ingress_intel_chat_improvements.user.js
// @downloadURL https://gist.github.com/raw/4415985/ingress_intel_chat_improvements.user.js
// @include http://www.ingress.com/intel*
// @version 8
// ==/UserScript==
 
// Public Domain. Please send improvements or suggestions
// to stefan+ingress@mathphys.fsk.uni-heidelberg.de
 
(function(){
function doStuffBefore() {
// try to load chat early
if(Re.prototype.$c.toString().indexOf("this.G.scrollTop") > 0) {
Re.prototype.$c = function(a) {
// load early, but only if there isn't already an ongoing loading
this.G.scrollTop <= 1200 && document.getElementById("pl_spinner") === null && a()
}
}
}
 
// inject as inline script element. So it executes after the ingress
// files have been loaded, but before they are executed.
var script = document.createElement("script");
var code = document.createTextNode(doStuffBefore.toString() + " doStuffBefore();");
script.appendChild(code);
document.getElementsByTagName("head")[0].appendChild(script);
 
 
 
 
// wait until jQuery is loaded
function wait() {
if(typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(wait, 100);
return;
}
unsafeWindow.jQuery(function() {
$ = unsafeWindow.jQuery;
// runs after Ingress' onload function
window.addEventListener("load", function() { doStuffAfter($); }, false);
});
}
wait();
 
 
function doStuffAfter($) {
// don't complete old messages
$("input#message, #passcode").attr("autocomplete", "off");
 
// rename 'all' tab
$("#pl_tab_all").text("Public");
 
// inject styles into page
$("head").append("<style>"
// hide restrict to map checkbox (who unchecks that anyway?)
+ "#pl_checkbox, #pl_checkbox_text { display: none }"
// hide superfluous [secure] messages in faction chat
+ ".chatFaction .pl_secure { display: none }"
// color faction yellow, so you know if the script is broken and
// you not really in faction chat
+ ".chatFaction #plext_container { background: rgba(64, 64, 37, 0.9) !important; }"
// there are no bot messages in faction chat, so hide the checkbox
+ ".chatFaction #hide_bot_stuff_checkbox { display: none }"
+ ".chatFaction #hide_bot_stuff_lbl { display: none }"
// place that checkbox somewhere less annoying
+ "#plext_viewport_restrict_checkbox_container { background: #272E32; box-shadow: none; right: 182px; padding-right:5px; top:21px }"
// color 'all' chat red
+ ".chatDanger #plext_container { background: rgba(54, 30, 30, 0.9) !important; }"
+ ".chatDanger #message { background: #361E1E !important } "
// hide unwanted plexts
+ ".hidePlext, .hidePlext2 { display:block;overflow:hidden;height:0;visiblity: hidden } </style>");
 
// listen for chat changes and add proper class to the chat elements
$("#pl_tab_all").click(function() {
$("#comm").addClass("chatDanger");
$("#comm").removeClass("chatFaction");
$("#message").attr("placeholder", "broadcast to everyone").focus();
botMessages();
});
$("#pl_tab_fac").click(function() {
$("#comm").removeClass("chatDanger");
$("#comm").addClass("chatFaction");
$("#message").attr("placeholder", "message faction").focus();
});
 
// switch to faction chat by default
$("#pl_tab_fac").click();
 
// insert msg only checkbox
$("#pl_checkbox_text").after(''
+ ' <input id="hide_bot_stuff_checkbox" type="checkbox">'
+ ' <label id="hide_bot_stuff_lbl" for="hide_bot_stuff_checkbox">hide bot msgs</label>');
 
// hides or shows bot messages depending on checkbox state. Also
// hides faction chat messages in 'all' chat
function botMessages() {
// hide faction chat in 'all' chat
$(".chatDanger .pl_secure").parent().parent().addClass("hidePlext2");
 
var hide = $("#hide_bot_stuff_checkbox").is(":checked");
if(hide)
$(".pl_broad, .pl_narrow").parent().addClass("hidePlext");
else
$(".hidePlext").removeClass("hidePlext");
}
 
// listen for clicks on checkbox and chat loading events
$("#hide_bot_stuff_checkbox").click(function() {
// find top element
elm = document.elementFromPoint(20, $(window).height() - $("#plext_container").height() - 20);
botMessages();
elm.scrollIntoView();
});
$("#pl_status").bind("DOMSubtreeModified", function() {
// only run when loading notice gets removed
if($(this).children().length != 0) return;
// only run in 'all' chat
if(!$("#comm").hasClass("chatDanger")) return;
 
var p = document.getElementById("plext_container");
var before = p.scrollHeight - p.scrollTop;
botMessages();
var hide = $("#hide_bot_stuff_checkbox").is(":checked");
 
// if there are very few chat messages enforce loading more
if($("#plexts").height() < 450) {
var f = $("#plext_container .plext:visible:first");
f.height(600);
p.scrollTop = 1;
f.height("");
}
 
// fix scrolling position
p.scrollTop = p.scrollHeight - before;
});
 
// prevent passcode field from collapsing and expand it right away
$("#passcode").attr("onmouseout", "");
// need timeout for Chrome
setTimeout("showpi(true);", 10);
}
})();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.