fmm / Load QLD LARGE & MEDIUM

// ==UserScript==
// @name         Load QLD LARGE & MEDIUM
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Load QLD LARGE & MEDIUM
// @author       You
// @match        https://metcash.retailpath.com.au/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let searchHeading = document.querySelector(".AESearchGroupHeading h1");

    let btn = document.createElement("button");
    btn.innerHTML = "QLD CORE";
    btn.style.display = "inline-block";
    btn.onclick = function (e) {
        e.preventDefault();
        setFilters(e.target);
        return false;
    };

    searchHeading?.appendChild(btn);

    function setFilters(el) {
        // clear all
        Search?.clearSelectionFromOtherSelects(el);

        let qld = document.evaluate("//input[contains(@value,'State pk:\"2\"')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        Search?.markSelection(qld);
        Search?.setChecked(qld.closest("td"));

        let large = document.evaluate("//input[contains(@value,'Brand pk:\"2\"')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        Search?.markSelection(large);
        Search?.setChecked(large.closest("td"));

        let medium = document.evaluate("//input[contains(@value,'Brand pk:\"1\"')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        Search?.markSelection(medium);
        Search?.setChecked(medium.closest("td"));

        let statusNew = document.evaluate("//input[contains(@value,'Status pk:\"2\"')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        Search?.markSelection(statusNew);
        Search?.setChecked(statusNew.closest("td"));

        let statusInProgress = document.evaluate("//input[contains(@value,'Status pk:\"1\"')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        Search?.markSelection(statusInProgress);
        Search?.setChecked(statusInProgress.closest("td"));
    }
})();