// ==UserScript==
// @name Unclutter VB5
// @namespace RattleSN4K3/EpicGames
// @description Cleans up forum, mainly by removing additional space and merging elements
// @include *//www.epicgames.com/unrealtournament/forums
// @include *//www.epicgames.com/unrealtournament/forums/*
// @require https://code.jquery.com/jquery-1.11.0.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/1.7.2/moment.min.js
// @version 1
// @author RattleSN4K3
// @grant none
// @run-at document-start
// @downloadURL https://update.greasyfork.icu/scripts/30319/Unclutter%20VB5.user.js
// @updateURL https://update.greasyfork.icu/scripts/30319/Unclutter%20VB5.meta.js
// ==/UserScript==
var IsProcessed = false;
var IsStickyHidden = false;
// add events for DOM and page loaded
document.addEventListener ("DOMContentLoaded", DOM_ContentReady);
window.addEventListener ("load", pageFullyLoaded);
function DOM_ContentReady () {
mainProc();
// check for mutations due to last/first-page links updated via Javascript
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
UpdatePaginationLinks(mutation.target);
});
// Stop observing if needed:
//this.disconnect();
});
$('.pagenav-container .js-pagenav-last-button, .pagenav-container .js-pagenav-first-button').each(function() {
observer.observe(this, {childList: true, subtree: true, attributes: true, attributeFilter: ['href']});
});
}
function pageFullyLoaded () {
momentProc();
window.setTimeout(checkAjaxInNewWindow, 500);
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
dynamicProc(mutation.target, true);
momentProc(mutation.target);
});
// Stop observing if needed:
//this.disconnect();
});
$('#topic-tab').each(function() {
observer.observe(this, {childList: true});
});
$('#thread-view-tab').each(function() {
observer.observe(this, {childList: true, subtree: true});
});
// observer for dialog
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach(function(addnode) {
if ($(addnode).hasClass('ui-dialog-content') == true) {
momentProc(addnode);
}
});
});
// Stop observing if needed:
//this.disconnect();
});
// start observing body for dynamically added dialogs
$('body').each(function() {
observer.observe(this, {childList: true});
});
}
function checkAjaxInNewWindow() {
var hasajaxcommand = false;
var urlparms = window.location.search.substr(1).split("&");
$.each(urlparms, function(index, item) {
if (item.startsWith("quote-") == true) {
hasajaxcommand = true;
var selector = '#'+item; //+' .b-post-control__label';
$(selector).trigger('click');
}
else if (item.startsWith("edit-") == true) {
hasajaxcommand = true;
var selector = '#'+item;
$(selector).trigger('click');
document.getElementById(selector).scrollIntoView();
}
if (index == urlparms.length - 1) {
if (hasajaxcommand == true) {
history.replaceState( {} , '', GetThreadURL() );
}
}
});
}
// hide logo and sub-forums manually with pure-Javascript and CSS before pages loads
(document.head || document.documentElement).insertAdjacentHTML('beforeend',
``);
function dynamicProc(root, ajaxloaded) {
ajaxloaded = ajaxloaded || false;
if (root === null) {
root = $(document);
}
if (ajaxloaded) {
if (!IsStickyHidden) {
IsStickyHidden = true;
$('head').prepend('