🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/06 06:04:03
🔄 下次更新时间:2026/01/06 07:04:03
手动刷新缓存

HWM_InfiniteScrollForProtocolPages

Бесконечная прокрутка страниц протоколов (добавление содержимого следующей страницы при прокрутке вниз)

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name        HWM_InfiniteScrollForProtocolPages
// @namespace   Рианти
// @description Бесконечная прокрутка страниц протоколов (добавление содержимого следующей страницы при прокрутке вниз)
// @include     /(heroeswm|178\.248\.235\.15|lordswm)[^\/]+\/(pl_warlog|pl_transfers|pl_cardlog|sklad_log|clan_log)/
// @version     1
// @grant       GM_xmlhttpRequest
// ==/UserScript==

var _timeoutOnAdding = 0; //ms
var _pixelsFromBottomBeforeAdding = 400;

var _isWarLog = document.location.href.includes('pl_warlog.php');
var _isCardLog = document.location.href.includes('pl_cardlog.php');
var _pageURLpattern = document.location.href.match(/[^\&]+/)[0] + '&page=';
var _addingInProgress = false;
var _curPage = 0;

if(document.location.href.includes('&page=')) _curPage = parseInt(document.location.href.match(/&page=(\d+)/)[1]);

window.addEventListener("scroll", checkIfNearBottom);

checkIfNearBottom();

function checkIfNearBottom(){
  if(_addingInProgress) return;
  var curWindowTop = window.pageYOffset;
  var contentTotalHeight = document.documentElement.clientHeight;
  var availToWebPageScreenHeight = window.innerHeight

  if(contentTotalHeight - _pixelsFromBottomBeforeAdding < curWindowTop + availToWebPageScreenHeight){
    _addingInProgress = true;
    getContentFromPageId(++_curPage, addNewContent);
  }
}

function getContentFromPageId(id, callbackFunc){
  requestPage (_pageURLpattern + id, function (dom){
    var t = dom.querySelector('body').innerHTML;
    t = t.substring(t.indexOf('<!-- big table -->') + 19, t.lastIndexOf('<!-- big table -->'));
    t = t.substring(t.indexOf('</center><br>') + 13, t.lastIndexOf('</td></tr></tbody></table>'));
    t = t.replace('</a></center><br>', '</a></center>');

    if(_isWarLog) t = alterContentForWarlogPage(t);
    if(_isCardLog) t = alterContentForCardlogPage(t);
    callbackFunc(t);
  });
}

function alterContentForCardlogPage(content){
  return '<table width="100%"><tr><td> </td></tr></table>' + content;
}

function alterContentForWarlogPage(content){
  return content.replace(/<a href="warlog\.php\?warid=(\d+)">([^<]+)<\/a>/g,
                        '<a href="warlog.php?warid=$1">$2</a><span>&nbsp;[<a href="http://' + document.location.host + '/war.php?lt=-1&amp;warid=$1" target="_blank">#</a>&nbsp;<a href="http://' + document.location.host + '/battlechat.php?warid=$1" target="_blank">chat</a>&nbsp;<a href="http://' + document.location.host + '/war.php?warid=$1" target="_blank">$</a>&nbsp;<a href="http://' + document.location.host + '/battle.php?lastturn=-3&amp;warid=$1" target="_blank">E</a>]</span>');
}

function addNewContent(contentHTML){
  var parent = document.querySelector('table[border="0"][cellpadding="0"][cellspacing="0"][width="95%"] > tbody > tr > td');
  if(!_isCardLog){
    var newChild = document.createElement('span');
    newChild.innerHTML = contentHTML;
    parent.appendChild(newChild);
  } else {
    parent.innerHTML += contentHTML;
  }
  setTimeout(function(){
    _addingInProgress = false;
    checkIfNearBottom();
  }, _timeoutOnAdding);
}

function requestPage (url, onloadHandler){
    console.log('[HWM_InfiniteScrollForProtocolPages] loading: ', url);
    try{
        GM_xmlhttpRequest({
            overrideMimeType: 'text/plain; charset=windows-1251',
            synchronous: false,
            url: url,
            method: "GET",
            onload: function(response){
                onloadHandler(new DOMParser().parseFromString(response.responseText, 'text/html').documentElement);
            },
            onerror: function(){ setTimeout( function() { requestPage (url, onloadHandler) }, 500 ) },
            ontimeout: function(){ requestPage (url, onloadHandler) },
            timeout: 5000
        });
    } catch (e) {
        console.log(e);
    }
}