Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name MTX Sort
- // @namespace http://tampermonkey.net/
- // @version 1
- // @description Sort MTX by price on Path of Exile's Main Site.
- // @author You
- // @match https://www.pathofexile.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // 1. find all blocks
- const container = document.querySelector('.shopItems')
- const alldivs = Array.from(container.querySelectorAll('.shopItem, .shopItemPackage'));
- // 2. sort them
- alldivs.sort((a, b)=>{
- let price_a = Number(a.querySelector('.price').textContent);
- let price_b = Number(b.querySelector('.price').textContent);
- return (price_a < price_b) ? -1 : 1;
- });
- alldivs.forEach((item, i)=>{
- // 3. update classes
- item.classList.remove('right-align');
- if (i % 2 == 1) {
- item.classList.add('right-align');
- }
- // 4. update DOM
- container.appendChild(item);
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement