MozillaZine

Script or stylesheet to sort low-to-high?

User Help for Mozilla Firefox
slickrcbd
 
Posts: 418
Joined: September 1st, 2010, 1:57 am

Post Posted October 15th, 2020, 3:46 pm

I'm shopping for some stuff on sites like Walmart, Target, Menard's, home Depot, etc.
Every time I click, it resets the "sort by" to either "best match" or "relevance" or something that puts the high-priced stuff first.
Is there a greasmonkey script or Stylus stylesheet to keep it set to low-to-high? An extension? Anything to reset this annoyance? I'm trying to refine my search by clicking on categories or filters, and it keeps resetting to show me the "can't afford it" stuff first.

morat
 
Posts: 4085
Joined: February 3rd, 2009, 6:29 pm

Post Posted October 15th, 2020, 8:30 pm

slickrcbd wrote:a greasmonkey script

I tested the Walmart site. As far as I know it's not possible to access the Shadow DOM when it's closed.

Code: Select all
document.querySelector('select[data-automation-id="utilbar-sort-filter"]').shadowRoot;

Image

Test page
http://www.walmart.com/search/?query=Knox%20Gelatin

Shadow DOM closed mode
http://stackoverflow.com/questions/39931284

slickrcbd
 
Posts: 418
Joined: September 1st, 2010, 1:57 am

Post Posted October 15th, 2020, 9:43 pm

Something is glitching here. Your code box just has one line, the "select all" button just takes me to the top of the page, and the rest of the code appears to be an image file that I'd have to type manually?
How would I install and use this?
Do I need to open a new window and transcribe it?
Why couldn't it be posted in the code box so I could just copy/paste? I'm NOT a coder, I don't have a clue how to make Greasemonkey Scripts or Stylus Stylesheets, I just assumed that I wasn't the only one annoyed by how the searches on major retailers worked and thought somebody else had already solved the problem. Why reinvent the wheel?

Sorry, I don't know how to test this, I usaully just look on userstyles (which is running really slow lately) or search for any grease-monkey scripts with Google since the demise of userscripts.org.

morat
 
Posts: 4085
Joined: February 3rd, 2009, 6:29 pm

Post Posted October 15th, 2020, 10:34 pm

It's possible to replace the url parameter in a greasemonkey script. (not tested)

Try this:

Code: Select all
// ==UserScript==
// @name         Walmart
// @match        http*://www.walmart.com/*
// @grant        none
// ==/UserScript==

(function () {

  "use strict";

  function replaceUrlParam(url, paramName, paramValue) {
    if (paramValue == null) {
      paramValue = '';
    }
    var pattern = new RegExp('\\b(' + paramName + '=).*?(&|#|$)');
    if (url.search(pattern) >= 0) {
      return url.replace(pattern, '$1' + paramValue + '$2');
    }
    url = url.replace(/[?#]$/, '');
    return url + (url.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue;
  }
  location.href = replaceUrlParam(location.href, 'sort', 'price_low');

})();

Replace url parameter
http://stackoverflow.com/a/20420424

Return to Firefox Support


Who is online

Users browsing this forum: No registered users and 11 guests