// ==UserScript==
// @name Soyjak.forum Auto-Refresh Notifications
// @namespace https://greasyfork.org/
// @version 1.4
// @description Refreshes the notification badge every 30 seconds on soyjak.forum without marking alerts as read
// @author You
// @match *://soyjak.forum/*
// @match *://*.soyjak.forum/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
const INTERVAL_MS = 30000; // 30 seconds
function isXenForo() {
return (
(typeof XF !== 'undefined' && XF.ajax) ||
(typeof XenForo !== 'undefined' && XenForo.ajax) ||
document.documentElement?.id === 'XF' ||
document.documentElement?.id === 'XenForo'
);
}
function poll() {
// Prefer modern XF2
if (typeof XF !== 'undefined' && XF.ajax && XF.canonicalizeUrl) {
// Very light endpoint that still returns the visitor counters
// (does NOT open or mark alerts as read)
XF.ajax(
'GET',
XF.canonicalizeUrl('index.php?whats-new/latest-activity'),
{},
null,
{
global: false, // no spinner
skipDefault: true,
error: function () {}
}
);
return;
}
// Fallback for older XenForo
if (typeof XenForo !== 'undefined' && XenForo.ajax) {
XenForo.ajax(
'index.php?misc/lightbox',
{},
function () {},
{
global: false,
error: function () {}
}
);
}
}
if (!isXenForo()) return;
setTimeout(() => {
poll();
setInterval(poll, INTERVAL_MS);
}, 2000);
})();