';
}
function RemoveMenu(){
$("#redditFixReloadAll").remove();
$("#redditFixReload25").remove();
}
function AddMenu(){
var menu = $("._2pUO1Sfe7WlIHvq6goN3Pz");
if (menu.find(".customRedditFixMenu").length > 0 )
return;
menu.append(getMenuItem('redditFixReloadAll', 'Reload All'));
$("#redditFixReloadAll").click(function(){
for (var i = topicsInMemory.length - 1; i >= 0; --i) {
var el = topicsInMemory.pop(i);
$(".rpBJOHq2PR60pnwJlUyP0").prepend(el);
}
maxOffset = $(document).height();
console.log(maxOffset);
});
menu.append(getMenuItem('redditFixReload25', 'Reload 25'));
$("#redditFixReload25").click(function(){
var reloadTill = topicsInMemory.length;
if (reloadTill > 25)
reloadTill = 25;
for (var i = 0; i < 25; ++i) {
var el = topicsInMemory.pop(i);
$(".rpBJOHq2PR60pnwJlUyP0").prepend(el);
}
maxOffset = $(document).height();
console.log(maxOffset);
});
}
$("#email-collection-tooltip-id").click(function(){
function _appendMenu() {
var menuMain = $('div[role="menu"]');
var isReady = menuMain.length > 0;
if (!isReady) {
setTimeout(_appendMenu, 100);
return;
}
if (menuMain.find("#fixRedditCustomMenuB").length == 0){
menuMain.find('a:last').before(getCheckBoxItem(commentEffects, "redditFixCheckBoxBackground", "Comment effects"));
$("#redditFixCheckBoxBackground").click(function(){
var btnBackgroundsChecked = $(this);
if (btnBackgroundsChecked.hasClass("_1L5kUnhRYhUJ4TkMbOTKkI")){
btnBackgroundsChecked.removeClass("_1L5kUnhRYhUJ4TkMbOTKkI");
localStorage.setItem("commentEffects", false);
commentEffects = "false";
}
else{
btnBackgroundsChecked.addClass("_1L5kUnhRYhUJ4TkMbOTKkI");
localStorage.setItem("commentEffects", true);
commentEffects = "true";
}
});
menuMain.find('a:last').before(getCheckBoxItem(holdTopicsInMemory, "fixRedditKeepTopicsInMemory", "Save topics in ram"));
$("#fixRedditKeepTopicsInMemory").click(function(){
var btnTopicsChecked = $(this);
if (btnTopicsChecked.hasClass("_1L5kUnhRYhUJ4TkMbOTKkI")){
btnTopicsChecked.removeClass("_1L5kUnhRYhUJ4TkMbOTKkI");
localStorage.setItem("holdTopicsInMemory", false);
holdTopicsInMemory = "false";
RemoveMenu();
}
else{
btnTopicsChecked.addClass("_1L5kUnhRYhUJ4TkMbOTKkI");
localStorage.setItem("holdTopicsInMemory", true);
holdTopicsInMemory = "true";
AddMenu();
}
});
menuMain.find('a:last').before(getCheckBoxItem(originalBehavior, "fixRedditoriginalBehavior", "Original behavior"));
$("#fixRedditoriginalBehavior").click(function(){
var btnTopicsChecked = $(this);
if (btnTopicsChecked.hasClass("_1L5kUnhRYhUJ4TkMbOTKkI")){
btnTopicsChecked.removeClass("_1L5kUnhRYhUJ4TkMbOTKkI");
localStorage.setItem("originalBehavior", false);
originalBehavior = "false";
}
else{
btnTopicsChecked.addClass("_1L5kUnhRYhUJ4TkMbOTKkI");
localStorage.setItem("originalBehavior", true);
originalBehavior = "true";
}
});
menuMain.find("a:last").before('
');
}
}
_appendMenu();
});
function callback() {
if (originalBehavior == "true")
return;
if (holdTopicsInMemory == "true")
AddMenu();
var st = $(document).scrollTop();
if (st > maxOffset)
{
if (st > lastScrollTop){
if ($(".scrollerItem").length > 50)
{
$(".scrollerItem").slice(0,9).each(function(){
var el = $(this);
if (el.offset().top == 0){
if (holdTopicsInMemory)
topicsInMemory.push(el.parent().parent());
el.parent().parent().remove();
st = 0;
}
});
}
}
lastScrollTop = st;
maxOffset = 0;
}
}
})();