Last active
November 17, 2018 04:46
-
-
Save amayatsky/df2adf11267ceca02b1d6a24dcc3e13d to your computer and use it in GitHub Desktop.
Remove all clutter from 2ch.hk but leave images, webm, mp4 and links intact
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var atriExtensionLoader = function() { | |
var console = window.console || { | |
"log": function(ix) {} | |
}; | |
console.log("AtriExtensions: revision 29"); | |
if (window.$) { | |
console.log("AtriExtensions: $ " + $.fn.jquery); | |
} else { | |
console.log("AtriExtensions: $ missing"); | |
return; | |
} | |
if (window.Store === undefined) { | |
console.log("AtriExtensions: Store missing"); | |
return; | |
} | |
Store.set("other.on_delete", "mark"); | |
var AtrExt = { | |
clsEnabled: false | |
}; | |
AtrExt.isThread = function() { | |
return window.location.href.indexOf("/res/") > 0; | |
}; | |
AtrExt.hideEnabled = function() { | |
return Store.get("atr_ext.hideEnabled", false); | |
}; | |
AtrExt.setHideEnabled = function(val) { | |
return Store.set("atr_ext.hideEnabled", val); | |
}; | |
AtrExt.highFilter = function() { | |
return Store.get("atr_ext.highFilter", "webm засмеялся mp4 цуиь обосрался шебм вебм"); | |
}; | |
AtrExt.setHighFilter = function(val) { | |
return Store.set("atr_ext.highFilter", val); | |
}; | |
AtrExt.filter = function() { | |
console.log("AtriExtensions: Filter"); | |
var keyWords = AtrExt.highFilter(); | |
function wordInString(string, keywords) { | |
string = (string + "").toLowerCase(); | |
keywords = keywords + ""; | |
return keywords.split(' ').some(function(keyword) { | |
return string.indexOf(keyword) === -1 ? false : true; | |
}); | |
} | |
$(".post.oppost").each(function(ix) { | |
if (wordInString($("blockquote", this).text(), keyWords)) { | |
$("#hidden-thread-n" + $(this).attr("data-num")).css("background-color", "#1cb8414f"); | |
$(this).parent().css("background-color", "#1cb8414f"); | |
} | |
}); | |
$(".reply.hidden-thread-box").each(function(ix) { | |
if (wordInString($("i", this).text(), keyWords)) { | |
$(this).css("background-color", "#1cb841"); | |
} | |
}); | |
}; | |
AtrExt.cls = function() { | |
console.log("AtriExtensions: cls, enabled: " + AtrExt.clsEnabled); | |
if (!AtrExt.clsEnabled) { | |
return; | |
} | |
$(".ABU-refmap, .post-reply-link").remove(); | |
$(".post-details:not(.oppost-wrapper *)").remove(); | |
$(".post-message a").each(function(ix) { | |
let button = $(this).next(".media-expand-button"); | |
let container = $(this).closest(".post"); | |
$(this).prev(".fa-media-icon").appendTo(container); | |
$(this).appendTo(container); | |
button.insertAfter($(this)); | |
$("<br />").insertAfter(button.length === 0 ? $(this) : button); | |
}); | |
$(".post-wrapper").filter(function(ix) { | |
return $(".images", this).length === 0 && $("a", this).length === 0; | |
}).hide(); | |
$(".post-message").hide(); | |
}; | |
AtrExt.bannerHide = function() { | |
$("section.moneymoneymoney").hide(); | |
$("div.logo").hide(); | |
$("#plashque").hide() | |
}; | |
AtrExt.dontHide = function(num) { | |
console.log("AtriExtensions: dontHide " + num); | |
Store.set("atr_ext.unhide." + window.board + "." + num, 7); | |
}; | |
AtrExt.hideAgain = function(num) { | |
console.log("AtriExtensions: hideAgain " + num); | |
Store.del("atr_ext.unhide." + window.board + "." + num, 7); | |
}; | |
AtrExt.hide = function() { | |
console.log("AtriExtensions: hide, enabled: " + AtrExt.hideEnabled() + ", isThread: " + AtrExt.isThread()); | |
if (AtrExt.hideEnabled() && !AtrExt.isThread()) { | |
var notHidden = (Store.get("atr_ext.unhide." + window.board) || {}); | |
$(".oppost .postbtn-hide").filter(":visible").filter(function(ix) { | |
return !notHidden.hasOwnProperty($(this).attr("data-num")); | |
}).trigger("click"); | |
} else { | |
Store.del("atr_ext.unhide." + window.board); | |
$(".hidden-thread-box").trigger("click"); | |
$(".hidden-p-box").trigger("click"); | |
} | |
}; | |
if (window.linkremover === undefined) { | |
console.log("AtriExtensions: window.linkremover undefined"); | |
} | |
window.linkremover = function() { | |
console.log("AtriExtensions: linkremover"); | |
AtrExt.cls(); | |
AtrExt.hide(); | |
AtrExt.bannerHide(); | |
AtrExt.filter(); | |
$(".reply.hidden-thread-box").off( "click.atrext.dontHide").on( "click.atrext.dontHide", function() { | |
AtrExt.dontHide($(this).attr("id").slice("hidden-thread-n".length)); | |
}); | |
$(".oppost .postbtn-hide").off("click.atrext.hideAgain").on( "click.atrext.hideAgain", function() { | |
AtrExt.hideAgain($(this).attr("data-num")); | |
}); | |
}; | |
if (window.linkUpdater === undefined) { | |
console.log("AtriExtensions: window.linkUpdater undefined"); | |
} | |
window.linkUpdater = function() { | |
console.log("AtriExtensions: linkUpdater"); | |
}; | |
$("<input type='button' value='Clear' id='btn_clear_atr' class='bb' style='z-index: 982;display: block;left:0px;min-width:60px'/>").prependTo($("body").first()); | |
$(document).on("click", "#btn_clear_atr", function() { | |
AtrExt.clsEnabled = true; | |
AtrExt.cls(); | |
}); | |
AtrExt.setHideLabel = function() { | |
$("#btn_hide_atr").val(AtrExt.hideEnabled() ? "Show" : "Hide"); | |
}; | |
if (!AtrExt.isThread()) { | |
$("<input type='button' value='Show/Hide' id='btn_hide_atr' class='bb' style='z-index: 982;display: block;left:60px;min-width:60px'/>").prependTo($("body").first()); | |
AtrExt.setHideLabel(); | |
$(document).on("click", "#btn_hide_atr", function() { | |
AtrExt.setHideEnabled(!AtrExt.hideEnabled()); | |
AtrExt.setHideLabel(); | |
AtrExt.hide(); | |
}); | |
$("<input type='text' class='bb' name='filter_atr_high' id='filter_atr_high' style='z-index:982;display: hidden;left:120px;min-width:240px;max-width:240px;background-color:white;'/>").prependTo($("body").first()); | |
$("#filter_atr_high").val(AtrExt.highFilter()); | |
$("<input type='button' value='H' id='btn_filter_high' class='bb' style='z-index: 982;display:block;left:120px;min-width:10px'/>").prependTo($("body").first()); | |
$(document).on("click", "#btn_filter_high", function() { | |
if ($("#filter_atr_high").is(":visible")) { | |
$("#filter_atr_high").hide(); | |
AtrExt.setHighFilter($("#filter_atr_high").val()); | |
$("#btn_filter_high").css("left", "120px"); | |
AtrExt.filter(); | |
} else { | |
$("#filter_atr_high").show(); | |
$("#btn_filter_high").css("left", "360px"); | |
} | |
}); | |
} | |
window.AtrExt = AtrExt; | |
//start | |
(function() { | |
$("#favorites-arrow-down").filter(".fa-angle-double-down").trigger("click"); | |
AtrExt.hide(); | |
AtrExt.bannerHide(); | |
AtrExt.filter(); | |
})(); | |
}; | |
if (window.Stage) { | |
Stage("AtriExtensions", "atri_ext", Stage.DOMREADY, atriExtensionLoader); | |
} else { | |
console.log("AtriExtensions: Stage missing"); | |
atriExtensionLoader(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment