Pyszniejsze

Changes filtering options to the pyszne.pl food delivery site

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            Pyszniejsze
// @author          jasieksor ([email protected])
// @namespace	    http://mojzesz.com/userscripts/pyszniejsze
// @description     Changes filtering options to the pyszne.pl food delivery site
// @include         https://pyszne.pl/restauracja*
// @version         1.0
// ==/UserScript==

// Change this variable to 1 to get ranges instead of "to" values
var rangeValues = 0;

/*
    Koszt dostawy
*/

var deliveryCostDiv = document.getElementsByClassName("atom-filter-wrapper")[1];

while (deliveryCostDiv.children[2]) {
    deliveryCostDiv.removeChild(deliveryCostDiv.lastChild);    
}

for (var i = 1; i < 5; i++) {
    var newParentLabel = document.createElement("label");
    newParentLabel.setAttribute("class", "atom-filter");

    var newOption = document.createElement("input");
    newOption.setAttribute("type", "radio");
    newOption.setAttribute("name", "jig-filter-deliverycost-button");
    newOption.setAttribute("id", i);
    newOption.setAttribute("class", "jig-filter-radio-button jig-filter-radio-button-" + i);

    if (rangeValues == 0)
        newOption.setAttribute("data-range", "[0, " + i*5 + "]");
    else if (i <= 1)
        newOption.setAttribute("data-range", "[" + (i-1)*5 + ", " + i*5 + "]");
    else 
        newOption.setAttribute("data-range", "[" + (i-1)*5 + ".1, " + i*5 + "]");
    
    var newLabel = document.createElement("span");
    newLabel.setAttribute("class", "filter-label");

    if (rangeValues == 0)
        newLabel.innerHTML = "Do " + i*5 + " zł";
    else 
        newLabel.innerHTML = (i-1)*5 + "-" + i*5 + " zł";

    newParentLabel.appendChild(newOption);
    newParentLabel.appendChild(newLabel);

    deliveryCostDiv.appendChild(newParentLabel);
}

/*
    Minimalny koszt zamówienia
*/

var minimumOrderDiv = document.getElementsByClassName("atom-filter-wrapper")[2];

while (minimumOrderDiv.children[1]) {
    minimumOrderDiv.removeChild(minimumOrderDiv.lastChild);    
}

for (var i = 1; i < 6; i++) {
    var newParentLabel = document.createElement("label");
    newParentLabel.setAttribute("class", "atom-filter");

    var newOption = document.createElement("input");
    newOption.setAttribute("type", "radio");
    newOption.setAttribute("name", "jig-filter-mincart-button");
    newOption.setAttribute("id", i);
    newOption.setAttribute("class", "jig-filter-radio-button jig-filter-radio-button-" + i);

    if (rangeValues == 0)
        newOption.setAttribute("data-range", "[0, " + i*5 + "]");
    else if (i <= 1)
        newOption.setAttribute("data-range", "[" + (i-1)*5 + ", " + i*5 + "]");
    else 
        newOption.setAttribute("data-range", "[" + (i-1)*5 + ".1, " + i*5 + "]");
    
    var newLabel = document.createElement("span");
    newLabel.setAttribute("class", "filter-label");

    if (rangeValues == 0)
        newLabel.innerHTML = "Do " + i*5 + " zł";
    else 
        newLabel.innerHTML = (i-1)*5 + "-" + i*5 + " zł";

    newParentLabel.appendChild(newOption);
    newParentLabel.appendChild(newLabel);

    minimumOrderDiv.appendChild(newParentLabel);
}