Skip to content

Instantly share code, notes, and snippets.

@rideride
Last active April 15, 2021 05:20
Show Gist options
  • Save rideride/cb6a2baaea1e734501e4e1a5b918493a to your computer and use it in GitHub Desktop.
Save rideride/cb6a2baaea1e734501e4e1a5b918493a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Live Counting Extension Lite
// @description Live Counting Extension Lite
// @author /u/
// @website https://github.com/rideride/
// @namespace http://tampermonkey.net/
// @include *://*.reddit.com/live/*
// @exclude *://*.reddit.com/live/create*
// @exclude *://*.reddit.com/live/*/edit*
// @exclude *://*.reddit.com/live/*/contributors*
// ==/UserScript==
// CONSTANTS
// Extension version
var VERSION = 'v1.7.0';
var USER = $('#header .user a[href]').html();
//Timestamp vars
var timestampEnable = true;
var darkcheck = 0;
var customClearTime;
var customStrickenColor;
var customBackgroundColor;
var timeCheck = 0;
setTimeout(function(){
timeCheck = 1;
}, 1000);
// Add context button
if(window.location.href.indexOf("updates") > -1) {
var contex = window.location.href;
contex = contex.replace('updates\/', '?after=LiveUpdate_');
$('.liveupdate-listing').prepend("<a id=contexter>context</a>");
$("#contexter").attr("href", contex).css("text-align","center").css("margin-bottom","15px").css("color","#369").css("background","#eee").css("display","block");
throw new Error();
}
// Thread ID
var THREAD = (function () {
var components = window.location.pathname.split('/');
for (var i = components.length - 1; i >= 0; i--) {
var component = components[i].trim();
if (component.length > 0)
return component.replace(/^.*\/([^/]*)/, "$1");
}
})();
////////////////
// Cookies.ts //
////////////////
// Adapted TypeScript version of the js-cookie library (https://github.com/js-cookie/js-cookie)
var Cookies = (function () {
function extend() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var i = 0;
var result = {};
for (; i < args.length; i++) {
var attributes = args[i];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init(converter) {
var api = function (key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
}
catch (e) { }
if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
}
else {
value = converter.write(value, key);
}
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, encodeURI);
return (document.cookie = [
key, '=', value,
attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '',
attributes.path ? '; path=' + attributes.path : '',
attributes.domain ? '; domain=' + attributes.domain : '',
attributes.secure ? '; secure' : ''
].join(''));
}
// Read
if (!key) {
result = {};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');
if (cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie);
}
catch (e) { }
}
if (key === name) {
result = cookie;
break;
}
if (!key) {
result[name] = cookie;
}
}
catch (e) { }
}
return result;
};
api.set = api;
api.get = function (key) {
return api.call(api, key);
};
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};
api.withConverter = init;
return api;
}
return init(function () { });
})();
///////////////
// Cookie.ts //
///////////////
// Uses the js-cookie library (lib/cookies.ts) for specialised cookie operations and intialization
var Cookie;
(function (Cookie) {
// INITIALIZATION
var cookieName = "LCE_Cookie";
var cookieVersion = '10';
// Try to load existing cookie save data, or create a cookie with default data
Cookie.saveDefaultOptions = true;
var save_default = {
version: cookieVersion,
options: {},
stats: {},
collapsed: [false, false, false, true, true],
customClearTime: 2000,
customStrickenColor: '#ddd',
customBackgroundColor: '#ddd'
};
Cookie.save = Cookies.getJSON(cookieName);
// In versions prior to 1.5.3, the extension used the cookie 'live-counting-extension'
// instead of 'LCE_{THREAD}'.
// To provide support for clients who had last used the extension at that point in time,
// we shall copy the contents of the cookie 'live-counting-extension' to 'LCE_{THREAD}'.
var oldCookie = Cookies.get('live-counting-extension');
if (oldCookie !== undefined && oldCookie !== null) {
if (Cookie.save === undefined || Cookie.save === null) {
Cookies.set(cookieName, oldCookie, { expires: 9000, path: '/live' });
Cookie.save = Cookies.getJSON(cookieName);
}
Cookies.remove('live-counting-extension', { path: '/live' });
}
// Create new cookie as it does not exist
if (Cookie.save === undefined || Cookie.save === null) {
Cookie.saveDefaultOptions = true;
Cookie.save = save_default;
update();
}
else if (Cookie.save.version != cookieVersion) {
Cookie.saveDefaultOptions = true;
Cookie.save.version = cookieVersion;
// If the current save is missing a few keys, add these keys, set to the default
for (var k in save_default) {
if (!Cookie.save.hasOwnProperty(k))
Cookie.save[k] = save_default[k];
}
update();
}
// METHODS
// Set the cookie value to `save`
function update() {
Cookies.set(cookieName, Cookie.save, { expires: 9000, path: '/live' });
}
Cookie.update = update;
})(Cookie || (Cookie = {}));
/////////////////
// Elements.ts //
/////////////////
var Elements;
(function (Elements) {
// PROPERTIES
// Important elements
Elements.$head = $('head');
Elements.$body = $('body');
Elements.$content = $('div.content');
Elements.$updates = $('.liveupdate-listing');
Elements.$options = $('#liveupdate-options');
Elements.$sidebar = $('aside.sidebar');
Elements.$form = $('#new-update-form');
Elements.$textarea = Elements.$form.find('textarea');
Elements.$submitBtn = Elements.$form.find('.save-button button');
Elements.$submitError = Elements.$form.find('.save-button .error');
// INITIALIZATION
Elements.$body.attr('id', 'lc-body');
// Prevent the larger $options from displacing the sidebar
// with different behaviour depending on whether or not textbox exists
if (Elements.$form.length) {
Elements.$form.after('<div style="clear:both;"></div>');
}
else {
Elements.$options.after('<div style="clear:both;"></div>');
}
// Make the submitError display default to none (important in RemoveSubmissionLag)
Elements.$submitError.css('display', 'none');
})(Elements || (Elements = {}));
;
///////////////
// Styles.ts //
///////////////
var Styles;
(function (Styles) {
// STYLESHEET
var $css = $("<style>\n\n\t/* General styles */\n\t#lc-body, #lc-body .liveupdate-listing {\n\t\tmin-width: 0px;\n\t}\n\n\t/* Prevent the button row from always showing up when screen is small */\n\t#lc-body li.liveupdate ul.buttonrow {\n\t\tdisplay: none !important;\n\t}\n\n\t#lc-body li.liveupdate:hover ul.buttonrow {\n\t\tdisplay: block !important;\n\t}\n\n\t/* Disable the transition entrance fade effect when an update is sent */\n\t#lc-body li.liveupdate * {\n\t\ttransition: none;\n\t}\n\n\t</style>");
// INITIALIZATION
$('head').append($css);
// METHODS
// Add code to stylesheet
function add(code) {
$css.append(code);
}
function replace(initial, newcode) {
var fix = $css.html().replace(initial, newcode);
$css.html(fix);
}
Styles.add = add;
Styles.replace = replace;
})(Styles || (Styles = {}));
////////////////
// Options.ts //
////////////////
var Options;
(function (Options) {
// INITIALIZATION
// Initialize new content in the options box
// TODO: move the $all to another core file since it will be used for stats as well
var $all_heading = $("\n\t\t<h1 style=\"font-size:16px;\">\n\t\t\t<a id=\"lceversion\" href=\"https://github.com/co3carbonate/live-counting-extension/blob/master/README.md#readme\" target=\"_blank\">Live Counting Extension " + VERSION + "</a> \n\t\t</h1>\n\t");
// var $options_heading = $("<h2>Options </h2>");
var $options_basic_heading = $("<h2>Basic </h2>");
var $options_advanced_heading = $("<h2>Advanced </h2>");
var $options_advanced2_heading = $("<h2>Advanced 2 </h2>");
var $all_toggle = $("<span class=\"toggle-trigger\" style=\"font-size:15px;\">[-]</span>");
var $options_toggle = $("<span class=\"toggle-trigger\">[-]</span>");
var $options_basic_toggle = $("<span class=\"toggle-trigger\">[-]</span>");
var $options_advanced_toggle = $("<span class=\"toggle-trigger\">[-]</span>");
var $options_advanced2_toggle = $("<span class=\"toggle-trigger\">[-]</span>");
var $all = $("<div id='live-counting-extension'></div>");
var $options = $("<div></div>");
var $options_basic = $("<div></div>");
var $options_advanced = $("<div></div>");
var $options_advanced2 = $("<div></div>");
$all_heading.append($all_toggle);
$all.append($options);
// $options_heading.append($options_toggle);
$options_basic_heading.append($options_basic_toggle);
$options_advanced_heading.append($options_advanced_toggle);
$options_advanced2_heading.append($options_advanced2_toggle);
$options.append($options_basic_heading, $options_basic, $options_advanced_heading, $options_advanced, $options_advanced2_heading, $options_advanced2);
Elements.$options.append($all_heading, $all);
var all_innerWidth = $all.innerWidth();
var all_offsetLeft = $all.offset().left;
// Handling toggle buttons ([-] and [+])
function toggle($trigger, $change, index) {
// bind click event listeners to the trigger
$trigger.on('click', function () {
if ($change.css('display') == 'none') {
// show
$trigger.html('[-]');
$change.slideDown(500);
Cookie.save.collapsed[index] = false;
}
else {
// hide
$trigger.html('[+]');
$change.slideUp(500);
Cookie.save.collapsed[index] = true;
}
Cookie.update();
});
// immediately trigger the click event if current cookie save is true
if (Cookie.save.collapsed[index])
$trigger.trigger('click');
}
// call
toggle($all_toggle, $all, 0);
toggle($options_toggle, $options, 1);
toggle($options_basic_toggle, $options_basic, 2);
toggle($options_advanced_toggle, $options_advanced, 3);
toggle($options_advanced2_toggle, $options_advanced2, 4);
// Styles
Styles.add("\n\n\t/* Subheadings */\n\t#live-counting-extension h2 {\n\t\tcolor: #4F4F4F;\n\t\tfont-size: 14px;\n\t\tfont-weight: bold;\n\t\tmargin: 8px 0px;\n\t}\n\n\t/* Toggle triggers */\n\t/* Don't specify #live-counting-extension for this, because the first trigger is actually outside the #live-counting-extension element */\n\t\n\t.toggle-trigger {\n\t\tcursor: pointer;\n\t\tcolor: #656565;\n\t\tfont-weight: normal;\n\t}\n\n\n\t/* Labels */\n\t#live-counting-extension label {\n\t\tdisplay: block;\n\t\tmargin-bottom: 10px;\n\t\tline-height: 160%;\n\t}\n\t\n\t");
// METHODS
// Add a checkbox option
// Returns the newly created checkbox
function addCheckbox(properties) {
// Handling properties
if (!properties.hasOwnProperty('section'))
properties.section = 'Basic';
if (!properties.hasOwnProperty('onchange'))
properties.onchange = null;
if (!properties.hasOwnProperty('default'))
properties["default"] = false;
if (!properties.hasOwnProperty('help'))
properties.help = '';
var label = properties["label"], section = properties["section"], onchange = properties["onchange"], defaultChecked = properties["default"], help = properties["help"];
// Default value handling (cookie)
var checked = defaultChecked;
if (Cookie.saveDefaultOptions && !Cookie.save.options.hasOwnProperty(label)) {
Cookie.save.options[label] = checked;
Cookie.update();
}
else
checked = Cookie.save.options[label];
// Create label and checkbox
var $elem = $("<input type=\"checkbox\"" + (checked ? ' checked="true"' : '') + "/>");
// Add option
var $options_section = $options_basic;
if (section == 'Basic')
$options_section = $options_basic;
else if (section == 'Advanced')
$options_section = $options_advanced;
else if (section == 'Advanced 2')
$options_section = $options_advanced2;
$options_section.append($("<label>" + label + "</label>")
.attr('title', help)
.prepend($elem));
// Handle onchange
$elem.on('change', function () {
Cookie.save.options[label] = $elem.prop('checked');
Cookie.update();
if (onchange != null)
onchange.call($elem);
});
// Trigger change event if the value != default
if (defaultChecked != checked)
$elem.trigger('change');
return $elem;
}
Options.addCheckbox = addCheckbox;
// Add select option
// Returns the newly created select
function addSelect(properties) {
// Handling properties
if (!properties.hasOwnProperty('section'))
properties.section = 'Basic';
if (!properties.hasOwnProperty('onchange'))
properties.onchange = null;
if (!properties.hasOwnProperty('default'))
properties["default"] = 0;
if (!properties.hasOwnProperty('help'))
properties.help = '';
var label = properties["label"], options = properties["options"], section = properties["section"], onchange = properties["onchange"], selectedIndex = properties["default"], help = properties["help"];
// Default value handling (cookie)
var defaultVal = options[selectedIndex];
var selectedVal = defaultVal;
if (Cookie.saveDefaultOptions && !Cookie.save.options.hasOwnProperty(label)) {
Cookie.save.options[label] = selectedVal;
Cookie.update();
}
else
selectedVal = Cookie.save.options[label];
// Create label and select
var $options_section;
var $elem = $("<select></select>");
if (section == 'Basic')
$options_section = $options_basic;
else if (section == 'Advanced')
$options_section = $options_advanced;
else if (section == 'Advanced 2')
$options_section = $options_advanced2;
$options_section.append($("<label>" + label + ": </label>")
.attr('title', help)
.append($elem));
// Configure the max-width of the select to ensure that it doesn't end up getting wrapped
// onto the next line
$elem.css('max-width', all_innerWidth - ($elem.offset().left - all_offsetLeft) + 'px');
// Set options of select
var elem_contents = '';
for (var i = 0; i < options.length; i++) {
elem_contents +=
"<option value=\"" + options[i] + "\"" + ((options[i] == selectedVal) ? ' selected="true"' : '') + ">" + options[i] + "</option>";
}
$elem.html(elem_contents);
// Handle onchange
$elem.on('change', function () {
Cookie.save.options[label] = $elem.val();
Cookie.update();
if (onchange != null)
onchange.call($elem);
});
// Trigger change event if the value != default
if (defaultVal != selectedVal)
$elem.trigger('change');
return $elem;
}
Options.addSelect = addSelect;
// WINDOW SIZE
// If sidebar turns into '[+] more about this live thread',
// (or window width < 700px according to CSS),
// move options to inside .sidebar
// New section in the sidebar for options
var $section = $("<section>\n\t\t<h2>options</h2>\n\t\t<div class='md'></div>\n\t</section>");
var $section_md = $section.children('.md');
$section.css('display', 'none').css('margin-top', '20px');
Elements.$sidebar.children('.sidebar-expand').after($section);
// Window resized
$(window).on('load resize', function () {
if (window.innerWidth <= 700) {
// add the options to '[+] more about this live thread'
if ($section.css('display') == 'none') {
$section.css('display', '');
$all.detach().appendTo($section_md);
}
}
else {
// remove the options from '[+] more about this live thread'
if ($section.css('display') != 'none') {
$section.css('display', 'none');
$all.detach().insertAfter($all_heading);
}
}
});
})(Options || (Options = {}));
///////////////
// Update.ts //
///////////////
var Update;
(function (Update) {
// UTILITY
// Get information about an update node
function getUpdateInfo($node) {
var data = {
elem: $node,
author: $node.find('.body > .author').text(),
body_elem: $node.find('.body > .md'),
author_elem: $node.find('.body > .author'),
href_elem: $node.find('.body > .md > p > em > a')
};
if (data.author)
data.author = data.author.trim().replace('/u/', '');
return data;
}
// METHODS
// Bind functions to execute in the following events:
// - loadedNew(): When a new update is sent
// - loadedOld(): When an old update is loaded
// - striked(): When an update is striked
// - TODO: deleted(): When an update is deleted
// loaded from top (new updates sent)
var funcLoadedTop = [];
function loadedNew(func) {
funcLoadedTop.push(func);
}
Update.loadedNew = loadedNew;
// loaded from bottom (scrolled down to load old updates)
var funcLoadedBottom = [];
function loadedOld(func) {
funcLoadedBottom.push(func);
}
Update.loadedOld = loadedOld;
// striked
var funcStriked = [];
function striked(func) {
funcStriked.push(func);
}
Update.striked = striked;
// EVENTS
// Setup MutationObserver on Elements.$updates
var observer = new MutationObserver(function (mutations) {
// Loop through MutationRecords and call the functions in various arrays based on .type
// (Honestly the MutationRecord[] usually only contains one, but whatever)
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
var mutation = mutations_1[_i];
// Addition / removal of child elements
// Executes loadedNew(), loadedOld(), deleted() functions accordingly
if (mutation.type == 'childList') {
// Setup variables for new updates or deleted updates
var $addedNodes = $(mutation.addedNodes).filter('.liveupdate');
var $removedNodes = $(mutation.removedNodes).filter('.liveupdate');
// Loop through new updates (if any)
$addedNodes.each(function (index, element) {
var $node = $(element);
if ($node.hasClass('preview'))
return; // ignore preview messages (RemoveSubmissionLag.ts)
// Get data about the new update
var data = getUpdateInfo($node);
// Check if the update was loaded from top or bottom
// Execute loadedNew() or loadedOld() functions accordingly
if ($node.index() == 0) {
// Loaded from top
// Execute loadedNew() functions
for (var _i = 0, funcLoadedTop_1 = funcLoadedTop; _i < funcLoadedTop_1.length; _i++) {
var func = funcLoadedTop_1[_i];
func(data);
}
}
else {
// Loaded from bottom
// Execute loadedOld() functions
for (var _a = 0, funcLoadedBottom_1 = funcLoadedBottom; _a < funcLoadedBottom_1.length; _a++) {
var func = funcLoadedBottom_1[_a];
func(data);
}
}
});
}
else if (mutation.type == 'attributes') {
// Setup
var $node = $(mutation.target);
if (!(mutation.oldValue && $node.attr('class')))
return;
var oldClasses = mutation.oldValue.split(' ');
var newClasses = $node.attr('class').split(' ');
// Must be a .liveupdate element
if (!$node.hasClass('liveupdate'))
return;
// Get data about the update
var data = getUpdateInfo($node);
// Check if the update had only now been stricken
if (oldClasses.indexOf('stricken') == -1
&& newClasses.indexOf('stricken') > -1) {
// Execute striked() functions
for (var _a = 0, funcStriked_1 = funcStriked; _a < funcStriked_1.length; _a++) {
var func = funcStriked_1[_a];
func(data);
}
}
}
}
});
observer.observe(Elements.$updates.get(0), {
// observe for insertion / removal of children updates
childList: true,
// observe for change in the 'class' attribute value
attributes: true,
attributeOldValue: true,
attributeFilter: ['class'],
// observe for these changes (particularly attributes changes) in descendants
subtree: true
});
})(Update || (Update = {}));
///////////////////
// ReplyTimes.ts //
///////////////////
var ReplyTimes;
(function (ReplyTimes) {
// INITIALIZATION
// Options
var enabledrt = true;
Options.addCheckbox({
label: 'ENABLE REPLY TIMES',
"default": true,
section: 'Advanced 2',
help: 'Enables LCE reply times.',
onchange: function () {
enabledrt = this.prop('checked');
timestampEnable = enabledrt;
}
});
Update.loadedNew(function (data) {
if (!enabledrt)
return;
var thisTime = data.elem.find('.body').prev().attr('href');
var timestamp_current = thisTime.substring(thisTime.indexOf("updates/") + 8);
timestamp_current = timestamp_current.substring(14, 18) + timestamp_current.substring(9, 13) + timestamp_current.substring(0, 8);
timestamp_current = parseInt(timestamp_current, 16);
var thisTime2 = data.elem.find('.body').parent().nextAll('.liveupdate:first').children().first().attr('href');
var timestamp_last = thisTime2.substring(thisTime2.indexOf("updates/") + 8);
timestamp_last = timestamp_last.substring(14, 18) + timestamp_last.substring(9, 13) + timestamp_last.substring(0, 8);
timestamp_last = parseInt(timestamp_last, 16);
var timestamp = timestamp_current - timestamp_last;
timestamp = timestamp / 10000;
timestamp = Math.round(timestamp);
var permalink = thisTime.substring(thisTime.indexOf("updates/") + 8);
var testhref = "https://old.reddit.com/live/" + THREAD + "/updates/" + permalink;
var colortest = '#7dd4fa';
var elcolor = '#000000';
var randomx = '0';
darkcheck = 0;
if (Elements.$body.attr('data-darkMode') == 'Default') {
if ($('#lc-body').hasClass('res-nightmode')) {
darkcheck = 1;
elcolor = '#ddd';
}
} else if (Elements.$body.attr('data-darkMode') == 'On') {
darkcheck = 1;
elcolor = '#ddd';
} else if (Elements.$body.attr('data-darkMode') == 'Off') {
darkcheck = 0;
}
if (timestamp <= -500) {
colortest = 'linear-gradient(to right,red,orange,yellow,green,blue,indigo,violet)';
} else if (-499 <= timestamp && timestamp < 1) {
colortest = '#f2ee0e';
if (darkcheck == 1) {colortest = '#727200';}
}
if (1 <= timestamp && timestamp < 100) {
colortest = '#ef7070';
if (darkcheck == 1) {colortest = '#4d0000';}
} else if (100 <= timestamp && timestamp < 200) {
colortest = '#ffaeae';
if (darkcheck == 1) {colortest = '#980000';}
} else if (200 <= timestamp && timestamp < 300) {
colortest = '#ffebba';
if (darkcheck == 1) {colortest = '#654700';}
} else if (300 <= timestamp && timestamp < 400) {
colortest = '#cfffba';
if (darkcheck == 1) {colortest = '#216e00';}
} else if (400 <= timestamp && timestamp < 500) {
colortest = '#a2e8af';
if (darkcheck == 1) {colortest = '#003b0b';}
} else if (500 <= timestamp && timestamp < 600) {
colortest = '#adffed';
if (darkcheck == 1) {colortest = '#006b53';}
} else if (600 <= timestamp && timestamp < 700) {
colortest = '#add6ff';
if (darkcheck == 1) {colortest = '#004183';}
} else if (700 <= timestamp && timestamp < 800) {
colortest = '#bcadff';
if (darkcheck == 1) {colortest = '#14006c';}
} else if (800 <= timestamp && timestamp < 900) {
colortest = '#e9adff';
if (darkcheck == 1) {colortest = '#460060';}
} else if (900 <= timestamp && timestamp < 1000) {
colortest = '#ffadf8';
if (darkcheck == 1) {colortest = '#6e0064';}
} else if (timestamp >= 1000) {
colortest = '#ededed';
if (darkcheck == 1) {colortest = '#2a2a2a';}
}
data.elem.find('.body').prepend("<div onclick=window.open('"+testhref+"'); id=river>"+timestamp+"</div>");
data.elem.find('#river').css('position', 'absolute').css('background',colortest).css('color',elcolor);
if(window.location.href.indexOf("10itx") > -1) {
var barregexy = /\/live\/.............\/updates\//
var barmagin = data.elem.find('.body').prev().attr('href');
var barmagin2 = barmagin.replace(barregexy, '');
var barmagin2p1 = barmagin2.substring(0, 8);
var barmagin2p11 = barmagin2.substring(9, 13);
var barmagin2p111 = barmagin2.substring(15, 18);
var barmagin2p1111 = barmagin2p111 + barmagin2p11 + barmagin2p1;
var barmagin2p2 = parseInt(barmagin2p1111, 16);
var mago = barmagin2p2.toString();
mago = mago.substring(0, 15);
mago = parseInt(mago);
mago = Math.round( mago * 10 ) / 10;
mago = mago / 10;
mago = Math.round(mago);
var dateTime = new Date( mago );
var dateTime2 = dateTime.toISOString();
var dateTime3 = dateTime2.substring(11, 23);
document.getElementById("river").innerHTML = dateTime3;
}
if (window.innerWidth >= 700) {
$( 'div#river' ).css('position', 'absolute').css('margin-left', '-135px').css('font-size', '9px').css('margin-top', '4px').css('width','120px').css('text-align','right').css('max-width','120px');
}
else {
$( 'div#river' ).css('position', 'absolute').css('margin-left', '-10px').css('font-size', '9px').css('margin-top', '-16px').css('width','120px').css('text-align','right').css('max-width','120px');
}
if ( $('#lc-body[data-DisplayMode="Minimal"] #liveupdate-statusbar').css('display') == 'none') {
$( 'div#river' ).css('margin-left', '-141px');
}
$("#river").mouseover(function() {
this.style.background = "transparent";
this.style.color = "transparent";
this.style.cursor = "pointer";
});
$("#river").mouseout(function() {
this.style.background = colortest;
this.style.color = elcolor;
});
});
$(window).on('load resize', function () {
if (window.innerWidth >= 700) {
$( 'div#river' ).css('position', 'absolute').css('margin-left', '-135px').css('font-size', '9px').css('margin-top', '4px').css('width','120px').css('text-align','right').css('max-width','120px');
$( '#idlecontainer' ).css('position','absolute');
}
else {
$( 'div#river' ).css('position', 'absolute').css('margin-left', '-10px').css('font-size', '9px').css('margin-top', '-16px').css('width','120px').css('text-align','right').css('max-width','120px');
$( '#idlecontainer' ).css('position','initial');
}
});
})(ReplyTimes || (ReplyTimes = {}));
///////////////////////////
// ReplyTimesDarkMode.ts //
///////////////////////////
var ReplyTimesDarkMode;
(function (ReplyTimesDarkMode) {
// INITIALIZATION
Elements.$body.attr('data-darkMode', 'Default');
// Options
Options.addSelect({
label: 'NIGHT MODE REPLY TIMES',
options: ['Default', 'On', 'Off'],
section: 'Advanced 2',
"default": 0,
help: 'Changes the background of reply times to better match RES night mode. Default = looks at RES, On = forced on, Off = forced off, even if RES night mode enabled',
onchange: function () {
Elements.$body.attr('data-darkMode', this.val());
}
});
})(ReplyTimesDarkMode || (ReplyTimesDarkMode = {}));
///////////////////////
// CustomStricken.ts //
///////////////////////
var CustomStricken;
(function (CustomStricken) {
// INITIALIZATION
Elements.$body.attr('data-customStricken', 'Off');
Elements.$body.attr('data-customStrickenColor', Cookie.save.customStrickenColor);
// Options
Options.addSelect({
label: 'CUSTOM STRICKEN',
options: ['Off', 'No Inverse', 'Inverse'],
section: 'Advanced 2',
"default": 0,
help: 'Applies custom styles to stricken counts.',
onchange: function () {
$(this).click(function(){
$(this).data('clicked', true);
});
Elements.$body.attr('data-customStricken', this.val());
//if (this.val() != 'Off' && $(this).data('clicked') == true) {
if (this.val() != 'Off' && timeCheck == 1) {
var oldStricken = Elements.$body.attr('data-customStrickenColor');
customStrickenColor = window.prompt('Enter your custom background color.','#ddd');
Cookie.save.customStrickenColor = customStrickenColor;
Elements.$body.attr('data-customStrickenColor', customStrickenColor);
Cookie.update();
Styles.replace("\n\n\t/* Custom Stricken */\n\t#lc-body[data-customStricken='No Inverse'] .liveupdate.stricken{\n\tbackground:" + oldStricken + "!important;\n\t}\n#lc-body[data-customStricken='Inverse'] .liveupdate.stricken{\n\tbackground:" + oldStricken + "!important;-webkit-filter: invert(100%);filter: invert(100%);\n\t}","\n\n\t/* Custom Stricken */\n\t#lc-body[data-customStricken='No Inverse'] .liveupdate.stricken{\n\tbackground:" + Elements.$body.attr('data-customStrickenColor') + "!important;\n\t}\n#lc-body[data-customStricken='Inverse'] .liveupdate.stricken{\n\tbackground:" + Elements.$body.attr('data-customStrickenColor') + "!important;-webkit-filter: invert(100%);filter: invert(100%);\n\t}");
}
}
});
// Styles
Styles.add("\n\n\t/* Custom Stricken */\n\t#lc-body[data-customStricken='No Inverse'] .liveupdate.stricken{\n\tbackground:" + Elements.$body.attr('data-customStrickenColor') + "!important;\n\t}\n#lc-body[data-customStricken='Inverse'] .liveupdate.stricken{\n\tbackground:" + Elements.$body.attr('data-customStrickenColor') + "!important;-webkit-filter: invert(100%);filter: invert(100%);\n\t}");
})(CustomStricken || (CustomStricken = {}));
//////////////////
// CtrlEnter.ts //
//////////////////
var CtrlEnter;
(function (CtrlEnter) {
// INITIALIZATION
Elements.$body.attr('data-submitShortcut', 'Ctrl+Enter');
var $textarea = $('#new-update-form textarea');
var $resVersion = $('#RESConsoleVersion');
var $submitBtn = $('#new-update-form .save-button button');
// Options
Options.addSelect({
label: 'SUBMIT SHORTCUT',
//options: ['Off', 'Ctrl+Enter', 'Enter', 'Custom'],
options: ['Off', 'Ctrl+Enter', 'Enter'],
section: 'Advanced',
"default": 1,
help: 'Changes the submit shortcut. May not work well with RES.',
onchange: function () {
Elements.$body.attr('data-submitShortcut', this.val());
/*if(Elements.$body.attr('data-submitShortcut') == "Custom") {
var customShortcut = window.prompt('Enter the js keycodes, separated by a comma Go to keycode.info to see keycodes easily.','13,17');
Elements.$body.attr('data-submitShortcut', customShortcut);
}*/
}
});
$textarea.on('keydown', function (e) {
if(Elements.$body.attr('data-submitShortcut') == "Off") {
return;
}
if(Elements.$body.attr('data-submitShortcut') == "Ctrl+Enter") {
if ($resVersion.length > 0 && +($resVersion.text().replace(/\D/g, '')) >= 478) {
return;
}
if (e.keyCode == 13 && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
$submitBtn.trigger('click');
}
}
if(Elements.$body.attr('data-submitShortcut') == "Enter") {
if (e.keyCode == 13) {
e.preventDefault();
$submitBtn.trigger('click');
}
}
});
})(CtrlEnter || (CtrlEnter = {}));
//////////////////
// CtrlSpace.ts //
//////////////////
var CtrlSpace;
(function (CtrlSpace) {
// INITIALIZATION
var enabled = true;
var $textarea = $('#new-update-form textarea');
// Bind keydown event to the textarea
if (enabled) {
$('body').on('keydown', function (e) {
if (e.keyCode == 32 && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
$textarea.focus();
}
});
}
})(CtrlSpace || (CtrlSpace = {}));
//////////////////
// KeepFocus.ts //
//////////////////
var KeepFocus;
(function (KeepFocus) {
// INITIALIZATION
var enabled = true;
var $submitBtn = $('#new-update-form .save-button button');
if (enabled) {
$submitBtn.mousedown(function(e) {
e.preventDefault();
});
}
})(KeepFocus || (KeepFocus = {}));
/////////////////////////
// ColoredUsernames.ts //
/////////////////////////
var ColoredUsernames;
(function (ColoredUsernames) {
// INITIALIZATION
// Specified colors for known users
var userColors = {
'SolidGoldMagikarp': '#008080',
'rschaosid': '#008080',
'live_mentions': 'Black',
'joinlivecounting': 'Black',
'livecounting_sidebar': 'Black',
'live_lc_bot': 'Black',
'Riverbot': 'Black',
'Graphite_bot': 'Black',
'b66b': 'Black',
'piyushsharma301': '#FF0F19',
'Tranquilsunrise': 'Orange',
'dominodan123': 'Blue',
'smarvin6689':'#060647',
'rideride':'#B22222',
'nomaur2':'#8A2BE2',
'VitaminB16': '#75CEAF',
'LeinadSpoon': '#520063',
'co3_carbonate': 'Grey',
'artbn': '#e66b00',
'amazingpikachu_38': '#FFFF00',
'qwertylool': "YellowGreen",
'TOP_20': '#ff00bf',
'80sFan02': '#0505BB',
'AstroMagician': '#2d8bff',
'NobodyL0vesMe': '#730099',
'PrinceCrinkle': '#0d2d89',
'noduorg':'#0d2d89',
'MrBahr12': '#00f20a',
'parker_cube': '#FF69B4',
'QuestoGuy': 'Purple',
'Smartstocks': '#840d0d',
'DemonBurritoCat':'#890003',
'gordonpt8': '#00FF00',
'Mooraell': '#DAA520',
'randomusername123458': '#00CC99',
'TheNitromeFan': '#fb72b0',
'Capitanbublo' : '#ff531a',
'davidjl123': '#6495ED',
'abplows':'#2B0090',
'Iamspeedy36': '#00BFFF',
'Phoenixness': '#ff0000',
'jillis6': '#ffd700',
'Kris18': '#0000ff',
'Chalupa_Dad':'#F08080',
'Majestic_Bear':'#4682B4',
'Flat-Mars-Society':'#00FF7F',
'xHOCKEYx12': 'Lime',
'_ntrpy': '#FF6600',
'o99o99': '#2BBDFF',
'afaintsmellofcurry': '#6799A0',
'KingCaspianX': '#191970',
'MewDP': '#FFFF33',
'DaveTheDave_': '#00BFFF',
'Luigi86101': '#006400',
'thetiredlemur': '#464942',
'TheGlobeIsRound': '#0080ff',
'CarbonSpectre': '#339933',
'Lonadont': '#a35252',
'TehVulpez': '#c42c0a',
'LC_Chats': '#dddddd',
'LC-3P0': 'Black',
'MaybeNotWrong': '#066666',
'ElliottB1': '#00FFDD',
'treje': '#ffc130',
'sakima11': '#0cd1ad',
'amazingpiakchu_38': '#FFFF00',
'royalpurplesky': '#800080',
'Mac_cy': '#FF8C00',
'iwannaplay5050': '#B22222',
'ludrol': '#191970',
'thegreatestminer': '#4F9D82',
'dogcatcowpig': '#1162f9',
'ItzTaken': '#32ff95',
'Noob2137': '#ff69ff',
'PaleRepresentative': '#2F4F4F',
'andrewtheredditor': '#2bdb6c',
'Whit4You': '#ff99ff',
'Rajalaxo': '#485432',
'NikinCZ': '#86D8CA',
'SecretAsianMa': '#373267',
'srmpass': '#ffeed6',
'MrUnderdawg': '#35e0cf',
'SsPincus': '#840d0d',
'amazingpikachu_37': '#FFFF00',
'basskro': '#346cd1',
'Chalupa_Grandpa': '#f69220',
'TOP_6689': '#006689',
'lyeinfyer': '#ccff99',
'Zaajdaeon': '#1776BF',
'Adventium_': '#228B22',
'NeonL1vesMatter': '#730099',
'Trial-Name': '#008080',
'TheMatsValk': '#00f5ff',
'supersammy00': '#28ad3c',
'ddodd69': '#a89332',
'NeitherLi2ardMisses': '#32ff94',
'----Redditisgood----': '#327aff',
};
if (USER == 'VitaminB16') {
userColors.b66b = 'white';
}
colortransfers = userColors;
// Possible colors for other users
var colors = ['Blue', 'Coral', 'DodgerBlue', 'SpringGreen', 'YellowGreen', 'Green', 'OrangeRed', 'Red', 'GoldenRod', 'CadetBlue', 'SeaGreen', 'Chocolate', 'BlueViolet', 'Firebrick'];
for (var i = colors.length - 1; i > 0; i--) {
// use Durstenfeld shuffle algorithm on colors array
var j = Math.floor(Math.random() * (i + 1));
var temp = colors[i];
colors[i] = colors[j];
colors[j] = temp;
}
function Shuffle(o) {
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
// index of next color to assign from colors array
var currentColor = 0;
// Options
var enabled = true;
Options.addCheckbox({
label: 'COLORED USERNAMES',
"default": true,
help: 'Makes the username in each message gain a unique color.\n\nCertain users who have specified their preferred username colors to /u/co3_carbonaate get that fixed color all the time. Otherwise, your color will be random and appear differently for everyone using the extension.',
onchange: function () {
enabled = this.prop('checked');
}
});
// EVENTS
// New update loaded
Update.loadedNew(function (data) {
if (!enabled)
return;
// Special usernames (temp rewards for top in 100k HoC, or other contributions)
// Bot-maker privileges
if (data.author == 'MaybeNotWrong' || data.author == 'co3_carbonate' || data.author == 'rschaosid' || data.author == 'piyushsharma301' || data.author == 'LeinadSpoon' || data.author == 'artbn') {
data.author_elem.css('font-weight', 'bold');
}
// Set username color
if (!userColors.hasOwnProperty(data.author)) {
userColors[data.author] = colors[currentColor];
currentColor++;
if (currentColor == colors.length) {
currentColor = 0;
}
}
data.author_elem.css('color', userColors[data.author]);
if(window.location.href.indexOf("110t4ltqqzi35") > -1 || window.location.href.indexOf("14ny3ur3axhd4") > -1) {
var lcchats = data.href_elem.attr('href');
lcchats = lcchats.trim().replace('/u/', '');
data.href_elem.css('color', userColors[lcchats]).css('fontStyle','initial').css('fontSize','13px');
if (lcchats == 'MaybeNotWrong' || lcchats == 'co3_carbonate' || lcchats == 'rschaosid' || lcchats == 'piyushsharma301' || lcchats == 'LeinadSpoon' || lcchats == 'artbn') {
data.href_elem.css('font-weight', 'bold');
}
}
});
if(window.location.href.indexOf("110t4ltqqzi35") > -1 || window.location.href.indexOf("14ny3ur3axhd4") > -1) {
$('a[href*="/u/"]').each(function() {
var thishref = $(this).attr('href');
thishref = thishref.trim().replace('/u/', '');
$(this).css('color', userColors[thishref]).css('fontStyle','initial').css('fontSize','13px');
if (thishref == 'MaybeNotWrong' || thishref == 'co3_carbonate' || thishref == 'rschaosid' || thishref == 'piyushsharma301' || thishref == 'LeinadSpoon' || thishref == 'artbn') {
$(this).css('font-weight', 'bold');
}
});
Update.loadedOld(function () {
$('a[href*="/u/"]').each(function() {
var thishref2 = $(this).attr('href');
thishref2 = thishref2.trim().replace('/u/', '');
$(this).css('color', userColors[thishref2]).css('fontStyle','initial').css('fontSize','13px');
if (thishref2 == 'MaybeNotWrong' || thishref2 == 'co3_carbonate' || thishref2 == 'rschaosid' || thishref2 == 'piyushsharma301' || thishref2 == 'LeinadSpoon' || thishref2 == 'artbn') {
$(this).css('font-weight', 'bold');
}
});
});
}
var burrentbolor = 0;
$('.author').each(function() {
var thisauthor = $(this).text().trim().replace('/u/', '');
//$(this).css('color', userColors[thisauthor]).css('fontStyle','initial').css('fontSize','13px');
if (!userColors.hasOwnProperty(thisauthor)) {
userColors[thisauthor] = colors[burrentbolor];
burrentbolor++;
if (burrentbolor == colors.length) {
burrentbolor = 0;
}
}
$(this).css('color', userColors[thisauthor]);
if (thisauthor == 'MaybeNotWrong' || thisauthor == 'co3_carbonate' || thisauthor == 'rschaosid' || thisauthor == 'piyushsharma301' || thisauthor == 'LeinadSpoon' || thisauthor == 'artbn') {
$(this).css('font-weight', 'bold');
}
});
Update.loadedOld(function () {
$('.author').each(function() {
var thisauthor = $(this).text().trim().replace('/u/', '');
//$(this).css('color', userColors[thisauthor]).css('fontStyle','initial').css('fontSize','13px');
if (!userColors.hasOwnProperty(thisauthor)) {
userColors[thisauthor] = colors[burrentbolor];
burrentbolor++;
if (burrentbolor == colors.length) {
burrentbolor = 0;
}
}
$(this).css('color', userColors[thisauthor]);
if (thisauthor == 'MaybeNotWrong' || thisauthor == 'co3_carbonate' || thisauthor == 'rschaosid' || thisauthor == 'piyushsharma301' || thisauthor == 'LeinadSpoon' || thisauthor == 'artbn') {
$(this).css('font-weight', 'bold');
}
});
});
})(ColoredUsernames || (ColoredUsernames = {}));
//////////////////////////
// ClearPastMessages.ts //
//////////////////////////
var ClearPastMessages;
(function (ClearPastMessages) {
// INITIALIZATION
var maxMessages = 50;
// Options
var enabled = true;
var enTimeout = false;
var $checkbox = Options.addCheckbox({
label: 'CLEAR PAST MESSAGES (REDUCES LAG)',
"default": true,
help: 'Frequently clears past messages from the page, which drastically negates lag and reduces the need to refresh constantly.',
onchange: function () {
enabled = this.prop('checked');
}
});
$checkbox.click(function() {
enTimeout = true;
setTimeout(function(){ enTimeout = false; }, 5000);
});
// EVENTS
// New update loaded
Update.loadedNew(function (data) {
if(window.scrollY==0 && enTimeout==false) {
if (!enabled) {
$checkbox.prop('checked', true).trigger('change');
}
}
if (!enabled)
return;
var $screenMessages = Elements.$updates.children('.liveupdate');
if ($screenMessages.length > maxMessages) {
$screenMessages.slice(maxMessages).remove();
}
});
// Old update loaded (scrolled to bottom)
Update.loadedOld(function (data) {
// disable
if (!enabled)
return;
$checkbox.prop('checked', false).trigger('change');
});
})(ClearPastMessages || (ClearPastMessages = {}));
////////////////////
// DisplayMode.ts //
////////////////////
var DisplayMode;
(function (DisplayMode) {
// INITIALIZATION
Elements.$body.attr('data-DisplayMode', 'Normal');
// "Return to Normal Display" button
var $returnBtn = $('<input type="button" value="Return to Normal Display"/>');
$returnBtn.on('click', function () {
$select.children('option[value="Normal"]').prop('selected', true).trigger('change');
});
$returnBtn.css({
marginBottom: '20px',
display: 'none',
margin: '0 auto'
});
Elements.$content.prepend($returnBtn);
// Options
var $select = Options.addSelect({
label: 'DISPLAY MODE',
options: ['Normal', 'Minimal'],
help: 'Changes the display interface of the page to your preference.',
onchange: function () {
var display = this.val();
$returnBtn.css('display', (display == 'Normal' ? 'none' : 'block'));
Elements.$body.attr('data-DisplayMode', display);
}
});
// Styles
Styles.add("\n\n\t/* Display Minimal */\n\t#lc-body[data-DisplayMode='Minimal'] #idlecontainer {left: -40%!important;} #lc-body[data-DisplayMode='Minimal'] #header,\n\t#lc-body[data-DisplayMode='Minimal'] #liveupdate-statusbar,\n\t#lc-body[data-DisplayMode='Minimal'] .markdownEditor-wrapper,\n\t#lc-body[data-DisplayMode='Minimal'] li.liveupdate time.live-timestamp,\n\t#lc-body[data-DisplayMode='Minimal'] #liveupdate-options, \n\t#lc-body[data-DisplayMode='Minimal'] aside.sidebar {\n\t\tdisplay: none;\n\t}\n\n\t#lc-body[data-DisplayMode='Minimal'] #liveupdate-header,\n\t#lc-body[data-DisplayMode='Minimal'] #new-update-form {\n\t\tmargin-left: 0px;\n\t}\n\n\t#lc-body[data-DisplayMode='Minimal'] li.liveupdate ul.buttonrow {\n\t\tmargin: 0 0 2em 0px !important;\n\t}\n\n\t#lc-body[data-DisplayMode='Minimal'] div.content {\n\t\tmax-width: " + Math.max(450, $('#new-update-form textarea').outerWidth()) + "px;\n\t}\n\n\t");
})(DisplayMode || (DisplayMode = {}));
////////////////////////////
// RemoveSubmissionLag.ts //
////////////////////////////
var RemoveSubmissionLag;
(function (RemoveSubmissionLag) {
// INITIALIZATION
var lastInput = '';
var enabled = true;
var ghostEnabled = false;
var previews = [];
var display = '';
// Options
Options.addSelect({
label: 'REMOVE SUBMISSION LAG',
options: ['Enabled', 'Disabled'],
"default": 0,
help: 'Upon submitting a message, the textbox is immediately cleared to allow you to enter new contents without waiting for your previous submission to be processed.\n\nYou can also stop Reddit from clearing the textbox.',
onchange: function () {
display = this.val();
enabled = display == 'Enabled';
}
});
// Styles
Styles.add("\n\n\t.liveupdate-listing li.liveupdate.preview {\n\t\topacity: 0.75;\n\t}\n\t.liveupdate-listing li.liveupdate.preview .live-timestamp {\n\t\tvisibility: hidden;\n\t}\n\n\t");
// EVENTS
// When message is submitted
Elements.$submitBtn.on('click', function (e) {
if (!enabled)
return;
setTimeout(function () {
var val = Elements.$textarea.val();
if (val.length == 0)
return;
// Clear textbox
Elements.$textarea.val('');
// This is a way to work around the issue where Reddit automatically clears the textbox
// when the update had been successfully delivered, although we just cleared it here.
// Call backupInput() whenever the textarea content is changed
Elements.$textarea.on('keydown keyup input', backupInput);
}, 0);
});
// In backupInput(), keep track of the last backed up textarea content, by storing in lastInput
function backupInput() {
lastInput = Elements.$textarea.val();
}
// Use MutationObserver on the 'error message' to detect when Reddit had cleared the textbox.
// When the error message's style changes from 'display: inline;' to 'display: none;', it
// is clear that Reddit had cleared the textbox.
// At this point, use the last backed-up input
var observer = new MutationObserver(function (mutations) {
if (!enabled)
return;
if (mutations.length != 1)
return;
// Exit if we think that Reddit had not cleared the textbox
var mutation = mutations[0];
if (!(mutation.oldValue == 'display: inline;' &&
Elements.$submitError.attr('style') == 'display: none;'))
return;
// Use the last backed-up input
Elements.$textarea.off('keydown keyup input', backupInput);
Elements.$textarea.val(lastInput);
lastInput = '';
});
if (Elements.$submitError.length > 0) {
observer.observe(Elements.$submitError.get(0), {
// observe for change in 'style' attribute value
attributes: true,
attributeOldValue: true,
attributeFilter: ['style']
});
}
})(RemoveSubmissionLag || (RemoveSubmissionLag = {}));
/////////////////////////////
// DisableUsernameLinks.ts //
/////////////////////////////
var DisableUsernameLinks;
(function (DisableUsernameLinks) {
// INITIALIZATION
Elements.$body.attr('data-DisableUsernameLinks', 'false');
// Options
Options.addCheckbox({
label: 'DISABLE USERNAME LINKS',
section: 'Advanced',
help: 'Disables the redirection to a user\'s profile upon clicking on his/her username. This is convenient to prevent yourself from accidentally going to one\'s profile page when trying to strike or delete a message.',
onchange: function () {
Elements.$body.attr('data-DisableUsernameLinks', this.prop('checked').toString());
}
});
// Styles
Styles.add("\n\n\t#lc-body[data-DisableUsernameLinks='true'] li.liveupdate > .body > .author {\n\t\tpointer-events: none;\n\t\tcursor: auto;\n\t}\n\n\t");
})(DisableUsernameLinks || (DisableUsernameLinks = {}));
////////////////////////
// LinksOpenNewTab.ts //
////////////////////////
var LinksOpenNewTab;
(function (LinksOpenNewTab) {
// INITIALIZATION
var $base = $('<base target="_blank">');
Elements.$head.append($base);
// Options
var enabled = true;
Options.addCheckbox({
label: 'MAKE ALL LINKS OPEN IN A NEW TAB',
"default": true,
section: 'Advanced',
help: 'Makes all links on the page open in a new tab.',
onchange: function () {
enabled = this.prop('checked');
if (enabled)
$base.attr('target', '_blank');
else
$base.attr('target', '_self');
}
});
})(LinksOpenNewTab || (LinksOpenNewTab = {}));
/////////////////////////
// DisableShortcuts.ts //
/////////////////////////
var DisableShortcuts;
(function (DisableShortcuts) {
// INITIALIZATION
// Options
var enabled = true;
Options.addCheckbox({
label: 'DISABLE OBSTRUCTIVE BROWSER SHORTCUTS',
"default": true,
section: 'Advanced',
help: 'Disables certain obstructive browser keyboard shortcuts. This currently disables the following: Ctrl+0 (Zoom Reset), Ctrl+[1-9] (Switch Tabs)',
onchange: function () {
enabled = this.prop('checked');
}
});
// EVENTS
$(document).on('keydown', function (e) {
if (!enabled)
return;
// Ctrl Hotkeys
if (e.ctrlKey || e.metaKey) {
// Ctrl+0 (Zoom Reset)
if (e.keyCode == 48)
e.preventDefault();
// Ctrl+[1-9] (Switch Tabs)
if (e.keyCode >= 49 && e.keyCode <= 57)
e.preventDefault();
// Ctrl+[numpad0-9] (as above)
if (e.keyCode >= 96 && e.keyCode <= 105)
e.preventDefault();
}
});
})(DisableShortcuts || (DisableShortcuts = {}));
////////////////////////
// ContentPosition.ts //
////////////////////////
var ContentPosition;
(function (ContentPosition) {
// INITIALIZATION
Elements.$body.attr('data-ContentPosition', 'Center');
// Options
Options.addSelect({
label: 'CONTENT POSITION',
options: ['Left', 'Center', 'Right'],
section: 'Advanced',
"default": 1,
help: 'Adjusts the position of the main content section.',
onchange: function () {
Elements.$body.attr('data-ContentPosition', this.val());
}
});
// Styles
Styles.add("\n\n\t#lc-body[data-ContentPosition='Left'] div.content {\n\t\tmargin: 0;\n\t}\n\t#lc-body[data-ContentPosition='Center'] div.content {\n\t\tmargin: 0 auto;\n\t}\n\t#lc-body[data-ContentPosition='Right'] div.content {\n\t\tfloat: right;\n\t}\n\n\t");
})(ContentPosition || (ContentPosition = {}));
//////////////////////
// LC_Chats_View.ts //
//////////////////////
var LC_Chats_View;
(function (LC_Chats_View) {
// Options
Elements.$body.attr('data-LC_Chats_View', false);
var lccTest = 0;
function lccAdda(h) {
if(h == 'yeah bro' && lccTest == 0) {
lccTest = 1;
$(`<iframe id="lc_chats_iframe" src="//www.redditmedia.com/live/14ny3ur3axhd4/embed" style=" position: absolute; left: 1%; width: 18%; top: 12%; height: 88%; "></iframe>`).insertAfter('.main-content');
Styles.add(`#lc-body[data-LC_Chats_View='true'] div.content { padding-left: 19%; }`);
}
else if(h == 'yeah bro' && lccTest == 2) {
lccTest = 1;
$('#lc_chats_iframe').css('display','initial');
} else if(h == 'nuh uh bro, also does this piss you off that im using strings like this? GOOD.' && lccTest == 1) {
lccTest = 2;
$('#lc_chats_iframe').css('display','none');
}
}
Options.addCheckbox({
label: 'LC Chats View',
"default": false,
section: 'Advanced',
help: 'Puts a small lil lc chats on da left side {:}',
onchange: function () {
Elements.$body.attr('data-LC_Chats_View', this.prop('checked'));
if(Elements.$body.attr('data-LC_Chats_View') == 'true') {
lccAdda('yeah bro');
}
if (Elements.$body.attr('data-LC_Chats_View') == 'false') {
lccAdda('nuh uh bro, also does this piss you off that im using strings like this? GOOD.');
}
}
});
})(LC_Chats_View || (LC_Chats_View = {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment