Advertisement
xpppppppaicyber

task sort

Jul 14th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function taskXCPX() {
  2.   // Select all the div elements inside the specified container
  3.   let elements = document.querySelectorAll("#__next > div > div.room-layout > div > div.Store_storeDialog__K3NJB > div.Store_box__j6_U4.Store_modal-box-container__S2ExC.commons_uikit__Nmsxg.commons_frame__f5hXE.commons_purpleinset___KfX2 > div > div.Store_store-tabs-wrapper__OfH4C > div > div > div.Store_items-content__FtMRE > div");
  4.  
  5.   // Array to store the extracted data
  6.   let data = [];
  7.  
  8.   elements.forEach((element, index) => {
  9.     // Get the inner text of the selected element
  10.     let innerText = element.innerText;
  11.  
  12.     // Split the inner text into an array based on newline characters
  13.     let textArray = innerText.split('\n');
  14.  
  15.     // Remove the first and last elements from the array
  16.     textArray.shift();
  17.     textArray.pop();
  18.  
  19.     // Select the first image inside the specified container if it exists
  20.     let rewardIcon = document.querySelector(`#__next > div > div.room-layout > div > div.Store_storeDialog__K3NJB > div.Store_box__j6_U4.Store_modal-box-container__S2ExC.commons_uikit__Nmsxg.commons_frame__f5hXE.commons_purpleinset___KfX2 > div > div.Store_store-tabs-wrapper__OfH4C > div > div > div.Store_items-content__FtMRE > div:nth-child(${index + 1}) > div > div > div.Store_card-header__FTHH8 > div:nth-child(2) > div > img`);
  21.  
  22.     // Select the second image inside the specified container if it exists
  23.     let taskIcon = document.querySelector(`#__next > div > div.room-layout > div > div.Store_storeDialog__K3NJB > div.Store_box__j6_U4.Store_modal-box-container__S2ExC.commons_uikit__Nmsxg.commons_frame__f5hXE.commons_purpleinset___KfX2 > div > div.Store_store-tabs-wrapper__OfH4C > div > div > div.Store_items-content__FtMRE > div:nth-child(${index + 1}) > div > div > div.Store_card-img-wrapper__hyk51 > img`);
  24.  
  25.     let rewardTask = textArray[0].padStart(4, 'ㅤ');
  26.     let tierTask = textArray[1].padStart(4, 'ㅤ');
  27.     let qtyTask = textArray[2].padStart(3, 'ㅤ');
  28.     let nameTask = textArray[3];
  29.     let rIcon = rewardIcon ? rewardIcon.src : '';
  30.     let tIcon = taskIcon ? taskIcon.src : '';
  31.  
  32.     // Push the extracted data into the array
  33.     data.push({
  34.       reward: rewardTask,
  35.       tier: tierTask,
  36.       qty: qtyTask,
  37.       name: nameTask,
  38.       rIcon: rIcon,
  39.       tIcon: tIcon
  40.     });
  41.   });
  42.  
  43.   // Sort the data array based on the reward task (assuming rewardTask is a number)
  44.   data.sort((a, b) => parseFloat(a.reward.replace(/ㅤ/g, '')) - parseFloat(b.reward.replace(/ㅤ/g, '')));
  45.  
  46.   // Generate the HTML content from the sorted data
  47.   let result = 'Reward ㅤ| Tier | Qty | Task <br>';
  48.   data.forEach(item => {
  49.     result += `${item.reward} <img src='${item.rIcon}' height='20px' width='20px'> | ${item.tier} | ${item.qty} | <img src='${item.tIcon}' height='20px' width='20px'> ${item.name} <br>`;
  50.   });
  51.  
  52.   // Set the HTML content to the div
  53.   const squareBox = document.getElementById('squareBox'); // Assuming squareBox is the id of your target div
  54.   squareBox.innerHTML = result;
  55.  
  56.   buttonNav();
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement