Firepatrol

Mark changes as patrolled on MediaWiki wikis.

// ==UserScript==
// @name			Firepatrol
// @version			4.2.2
// @namespace		itsafeature.org
// @description	    Mark changes as patrolled on MediaWiki wikis.
// @icon            data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wIQCBoKW45C2AAAIABJREFUeNrtnWecXMWVt5+quvd27pmePCONwijnhAKIIBDIYDA52BgTHDA2LI4LNqzj2uuwBgP2YrO2wQYDJgchkyywACEklPMoj8Lk2D2dbqh6P3j9/n67Xu9i1oAk+vnaM7dOnfPvU+FW14ESJUqUKFGiRIkSJUqUKFGiRIkSJUqUKFGiRIkSJUqUKFGiRIkSJUocPYiSC44upqfEhsZkmI1deaclx4T/7e+tksuOCqKXjQq/IqSZVW6BbysikTh6f+7CAzn9aEkARys2Qy6uCT2u4mpOTEl8rfGExGhDREHIlo+AFiUBHIWMLZcvz0rZC2KREDFcCr6HpRyKgUEHAYEwCLiiNAQcRUytDIvdvYWZCxqjdw+PyikNCYkJXPLSQXqawNO40lDUGqNtKqN68c6BkgCOGixTmHlaY3j1iUNsRiUNXQVJVyGMzhcRWmOkwgQaT2v6XcnOXi9bygBHCZNr5J3zy5OfuWG+xa6+gJVthr6ci2sEjh1CCo+wtPAM+NKwYSB/e08RtySAo2JpF2n+1inJMafVSX75Wo69xQAvCLAcC6kDHFNAhUL0e0VyUtJT8IDQDeD/r8+WJfcengwNJQXSGf/xYeHtr329bkwmlxNXL8mwtLPAnsE8fS5k8gEhyyLhWIyKaKoiEYLAprnXYld/wX0r7fxdM8CvPzLk2o999xhX7y9iPXuQ436weesKWH6MjVjtYUphfWtMS4bEhnT62C+cXrX85o9Uc9VN+5C2wNUBxkikDmOkxkYSkh4zqkI4lmJXp0fbYEHvyXjqLc8r/l5G93739ObUdSPHBD9ZKazdaTyleP2fprF+ZTep6ti5Ix7Y8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uB96MUnpqmH/pQSU2Ulz5QoUaJEiRIlSpQoUaJEiRIlSpQoUaJEiRIlSpQoUaJEiRIlSpQoUaJEiRIlSpQ4ovh/AIXAlolkc9IAAAAASUVORK5CYII=
// @match           https://*/*diff=*
// @match           https://*/*action=markpatrolled*
// @match           https://*/*wiki*
// @grant           window.close
// @grant           GM_notification
// ==/UserScript==

// Firepatrol marks unreviewed (unpatrolled) changes as reviewed (patrolled).
// It uses the shortcut M. When the change has already been patrolled,
// you are taken to the next page.

let language = 1; // 0 is Dutch, 1 is English
let f9KeyEnabled = true; // Mark as patrolled with F9
let mKeyEnabled = true; // Mark as patrolled with m
let tKeyEnabled = true; // Send thanks with t
let closeTabAfterPatrol = true; // dom.allow_scripts_to_close_windows needs to be true in Firefox, in Chrome this won't work

(function(){

document.addEventListener('keydown', async function(e) {
	let patrolled = ["Gemarkeerd!", "Patrolled!"];
	let tryagain = ["Probeer opnieuw", "Try again"];
	let marking = ["Markeren als gecontroleerd...", "Marking as patrolled..."];

	const userLang = navigator.language;
	if(userLang.startsWith("nl-") || userLang == "nl"){
		language = 0;
	}

    function optionallyCloseTab(markedAsPatrolled){
        let timeout = 200;
        if(markedAsPatrolled == false) timeout = 0;

		// there is no next link
		if(closeTabAfterPatrol){
			setTimeout(function(){
				window.close();
			}, timeout);
		}
	}

	function doNextAction(nextLink, markedAsPatrolled){
		if(nextLink === null){
		 	optionallyCloseTab(markedAsPatrolled);
		}else{
			window.location.href = nextLink;
		}
	}

	async function doMark(){
        let nextLink = document.querySelector("#differences-nextlink");

        let patrolLink = document.querySelector(".patrollink");
        if(window.location.href.includes("diff") == false && window.location.href.includes("action=") == false){
            if(patrolLink == undefined){
                return; // Unwanted behaviour, nothing to mark
            }
        }

		if(patrolLink == undefined){
            doNextAction(nextLink, false);
            return;
		}
		patrolLink.getElementsByTagName("a")[0].click();
        const clicked = await GM.notification({ text: patrolled[language], timeout: 1000 });

		doNextAction(nextLink, true);
	}

    function sendThanks(){
        let thanksLink = document.querySelector(".mw-thanks-thank-link");
        if(thanksLink == undefined) return;
        thanksLink.click();

        setTimeout(function(){
            let thanksLink1 = document.querySelectorAll(".mw-thanks-thank-link")[1];
            thanksLink1.click();
        }, 100);
    }

    if (((f9KeyEnabled&& e.key == 'F9') || (mKeyEnabled && e.key == 'm')) && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
        // get mark as patrolled. If not available, this page might be already marked as patrolled
        let textContextPatrolLink = document.querySelector(".patrollink")?.getElementsByTagName("a")[0];
        if(textContextPatrolLink != undefined) textContextPatrolLink.textContent = marking[language];

        if(document.readyState == "complete"){
            await doMark();
        }
    }

    if(tKeyEnabled == true){
        if (e.key == 't' && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
            // Send thanks if possible. If not available, the user might be already thanked
            if(document.readyState == "complete"){
                sendThanks();
            }
        }
    }
}, false);

})();