Update Apaczka shipment methods and add support for ApaczkaP2P
This commit is contained in:
78
apilo.js
78
apilo.js
@@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name A
|
||||
// @version 2.0
|
||||
// @version 2.2
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
@@ -94,10 +94,11 @@
|
||||
|
||||
const buttons = [
|
||||
createButton('Apaczka D2D Inpost', '#7039df', 'ApaczkaD2D'),
|
||||
createButton('Furgonetka P2D Inpost', '#007bff', 'P2D.inpost', 'RZE14N||RZE14N'),
|
||||
createButton('Furgonetka D2P Inpost', '#28a745', 'D2P.inpost'),
|
||||
createButton('Apaczka P2P Inpost', '#7039df', 'ApaczkaP2P'),
|
||||
createButton('Furgonetka P2D Inpost', '#ff7800', 'P2D.inpost', 'RZE14N||RZE14N'),
|
||||
createButton('Furgonetka D2P Inpost', '#ff7800', 'D2P.inpost'),
|
||||
createButton('Furgonetka D2D Inpost', '#ff7800', 'D2D.inpostkurier'),
|
||||
createButton('Furgonetka P2P Inpost', '#ffc107', 'P2P.inpost', 'RZE14N||RZE14N')
|
||||
createButton('Furgonetka P2P Inpost', '#ff7800', 'P2P.inpost', 'RZE14N||RZE14N')
|
||||
];
|
||||
|
||||
buttons.forEach(button => buttonContainer.appendChild(button));
|
||||
@@ -414,8 +415,12 @@
|
||||
if (method.startsWith('Apaczka')) {
|
||||
console.log('Ustawianie wysyłki Apaczka...');
|
||||
await setCarrierAccount();
|
||||
await setPackageTypeApaczka();
|
||||
await setShipmentMethodApaczka();
|
||||
await setShipmentMethodApaczka(method);
|
||||
|
||||
if (method === 'ApaczkaP2P') {
|
||||
await setDropoffPoint('RZE14N||RZE14N');
|
||||
}
|
||||
|
||||
await setPreferencesContentApaczka();
|
||||
await setParcelWeight('1');
|
||||
await submitShipment();
|
||||
@@ -457,40 +462,33 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Funkcja ustawiająca typ paczki na "PACZKA" dla Apaczki.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function setPackageTypeApaczka() {
|
||||
return waitForElement('#warehousebundle_shipment_packageType').then(packageTypeElement => {
|
||||
packageTypeElement.value = 'PACZKA';
|
||||
const event = new Event('change', { bubbles: true });
|
||||
packageTypeElement.dispatchEvent(event);
|
||||
console.log('Typ paczki ustawiony na PACZKA.');
|
||||
}).catch(error => {
|
||||
console.error('Nie udało się ustawić typu paczki:', error);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Funkcja ustawiająca metodę wysyłki na "42" dla Apaczki.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function setShipmentMethodApaczka() {
|
||||
return retryUntilSuccess(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const methodElement = document.getElementById('warehousebundle_shipment_method');
|
||||
if (methodElement) {
|
||||
methodElement.value = '42';
|
||||
const event = new Event('change', { bubbles: true });
|
||||
methodElement.dispatchEvent(event);
|
||||
console.log('Metoda wysyłki ustawiona na 42 (Apaczka).');
|
||||
resolve();
|
||||
} else {
|
||||
reject('Nie znaleziono elementu warehousebundle_shipment_method');
|
||||
}
|
||||
});
|
||||
});
|
||||
* Funkcja ustawiająca metodę wysyłki na podstawie typu Apaczki.
|
||||
* Upewnia się, że select nie jest pusty przed ustawieniem wartości.
|
||||
* @param {string} method - Typ Apaczki ('ApaczkaD2D' lub 'ApaczkaP2P').
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function setShipmentMethodApaczka(method) {
|
||||
return retryUntilSuccess(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const methodElement = document.getElementById('warehousebundle_shipment_method'); console.log( methodElement );
|
||||
if (methodElement) {
|
||||
if (methodElement.options.length > 0) {
|
||||
methodElement.value = (method === 'ApaczkaP2P') ? '41' : '42';
|
||||
const event = new Event('change', { bubbles: true });
|
||||
methodElement.dispatchEvent(event);
|
||||
console.log(`Metoda wysyłki ustawiona na ${(method === 'ApaczkaP2P') ? '49 (ApaczkaP2P)' : '42 (ApaczkaD2D)'}.`);
|
||||
resolve();
|
||||
} else {
|
||||
reject('Select #warehousebundle_shipment_method jest pusty.');
|
||||
}
|
||||
} else {
|
||||
reject('Nie znaleziono elementu warehousebundle_shipment_method');
|
||||
}
|
||||
});
|
||||
}, 500, 20).catch(error => {
|
||||
console.error('Nie udało się ustawić metody wysyłki:', error);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
BIN
autoload/front/.DS_Store
vendored
BIN
autoload/front/.DS_Store
vendored
Binary file not shown.
BIN
templates/.DS_Store
vendored
BIN
templates/.DS_Store
vendored
Binary file not shown.
Reference in New Issue
Block a user