@anotherusername feel free to steal from mine. it includes refocusing on the selected post after jellypotato, and includes nodebb hooks.
// ==UserScript==
// @name tdwtf forum - unfuck image loading
// @namespace Lorne
// @include https://what.thedailywtf.com/topic/*
// @version 1
// @grant none
// @runat document-end
// ==/UserScript==
var $ = unsafeWindow.jQuery;
function DoStupidScroll()
{
var $ = unsafeWindow.jQuery;
var $hl = $(".highlight");
if($hl.length > 0)
{
$('html, body').animate({scrollTop: $hl.offset().top}, 100);
}
}
$(document).ready(function()
{
$(window).on('action:topic.loaded', function(event, data)
{
DoStupidScroll();
// image load hook
$("img").load(function(e)
{
DoStupidScroll();
});
});
/*
$(document).on("load", "img", function(e) { console.log("image loaded", this); });
// $(".img-responsive").bind("changeData": function() {console.log("data was changed"); } );
// $(".img-responsive").bind("setData": function() {console.log("data was setData"); });
// $("img").load(function(e) { console.log("image loaded2", this); });
$(document).on("action:post.tools.load", "*", function(e) { console.log("action:post.tools.load"); });
$(document).on("action:topic.loaded", "*", function(e) { console.log("action:post.tools.load"); });
$(document).on("action:ajaxify.dataLoaded ", "*", function(e) { console.log("action:ajaxify.dataLoaded "); });
*/
LoadImagesForce();
console.log("document ready");
});
function LoadImagesForce()
{
var $ = unsafeWindow.jQuery;
var $imgs = $(".img-responsive");
// console.log($imgs);
$imgs.each(function()
{
var $ = unsafeWindow.jQuery;
var $this = $(this);
// console.log(this);
// console.log("this.src", $this.attr("src"));
// console.log("this.data.src", $this.data("src"));
//console.log("this.data.state", $this.data("state"));
if($this.attr("src")=="about:blank")
{
// console.log("loading ", this);
$this.data("state", "loaded");
$this.attr("data-state", "loaded");
$this.attr("src", $this.data("src"));
// console.log("loaded ", this);
}
//console.log('$this.data("src") = ', $this.data("src"));
//console.log('$this.attr("src") = ', $this.attr("src"));
});
setTimeout(LoadImagesForce, 2000);
}```