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.
Script or stylesheet to sort low-to-high?
-
- Posts: 553
- Joined: September 1st, 2010, 1:57 am
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: Script or stylesheet to sort low-to-high?
I tested the Walmart site. As far as I know it's not possible to access the Shadow DOM when it's closed.slickrcbd wrote:a greasmonkey script
Code: Select all
document.querySelector('select[data-automation-id="utilbar-sort-filter"]').shadowRoot;
Test page
http://www.walmart.com/search/?query=Knox%20Gelatin
Shadow DOM closed mode
http://stackoverflow.com/questions/39931284
-
- Posts: 553
- Joined: September 1st, 2010, 1:57 am
Re: Script or stylesheet to sort low-to-high?
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.
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.
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: Script or stylesheet to sort low-to-high?
It's possible to replace the url parameter in a greasemonkey script. (not tested)
Try this:
Replace url parameter
http://stackoverflow.com/a/20420424
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');
})();
http://stackoverflow.com/a/20420424