Skip to content

Instantly share code, notes, and snippets.

@shakedlokits
Last active April 7, 2022 20:03
Show Gist options
  • Save shakedlokits/de384b41a3e422febc943971e4ded5ff to your computer and use it in GitHub Desktop.
Save shakedlokits/de384b41a3e422febc943971e4ded5ff to your computer and use it in GitHub Desktop.
Sort Wolt Categories
// ==UserScript==
// @author Shaked Lokits
// @name Sort Wolt Categories
// @description Allows to sort wolt categories by rating
// @icon https://static.wolt.com/favicon.ico
// @version 0.1.0
// @run-at document-idle
// @include https://wolt.com/*/discovery/category-*
// @require http://code.jquery.com/jquery-latest.js
// @require https://raw.githubusercontent.com/lodash/lodash/4.17.4/dist/lodash.js
// @grant none
// ==/UserScript==
function updateSorting() {
const list = $('div[class*=VenueVerticalList]');
const items = list.find($('a[class*=DiscoveryVenueListItem]'));
const ratings = items.map(index => {
const item = items.get(index);
const rating = $(item).find($('span[class*=VenueCardFooter__FooterContent]')).get(5).textContent;
return { item, rating };
});
const sortedItems = _.sortBy(ratings, ['rating']).map(r => r.item).reverse();
list.get(0).replaceChildren(...sortedItems);
};
GM_registerMenuCommand('Sort wolt venues', updateSorting);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment