// ==UserScript==
// @name HF Infiniscroll
// @author emanb29
// @namespace http://hackforums.net/
// @version 0.8
// @description A userscript to enhance HF by providing infinite scrolling on thread listings and post listings
// @include *hackforums.net/*
// @copyright 2014+, emanb29
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_log
// @grant GM_info
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @downloadURL https://update.greasyfork.icu/scripts/13188/HF%20Infiniscroll.user.js
// @updateURL https://update.greasyfork.icu/scripts/13188/HF%20Infiniscroll.meta.js
// ==/UserScript==
if (window.location.href.match(".+://.*\\.?hackforums\\.net/showthread\\.php\\?tid=[0-9]+")){
GM_log('tid match');
var tid = window.location.href.match("tid=[0-9]+")[0],
maxpgs,
page = 1,
allow = true,
setting = true,
postid;
$('.pagination').append('');
if (getSettings("iScroll") === null){saveSettings("iScroll", true)}
if (getSettings("iScroll") === true){
$('.ScrollImg').attr("src", "http://i.imgur.com/M4Bu1Zp.png");
setting = true;
}
if (getSettings("iScroll") === false){
$('.ScrollImg').attr("src", "http://i.imgur.com/H2OONnP.png");
setting = false;
}
try {
maxpgs = ($('a[class="pagination_next"]')[0]) ? $('a[class="pagination_next"]').prev()[0].innerHTML : $('span[class="pagination_current"]')[0].innerText;
} catch (ex) {
maxpgs = 1;
}
page = document.getElementsByClassName("pagination_current")[0].innerText;
postid = $('#posts');
$(window).scroll(function () {
if (setting === true){
var height = $(document).height() - $(window).height();
if ($(window).scrollTop() === height){
console.log("infiniscroll");
}
}
});
function request(page){
$.ajax({
type: "get",
url: "/showthread.php?" + tid + "&page=" + page,
dataType: "html",
success: function (data){
$(data).find('div#posts').each(function(){
postid.last().append('
| ' +
' ' +
'Page: ' + page + '' +
' ' +
' | ' +
'