Use Greasemonkey To modify Craigslist's default, search-results sorting?

Use Greasemonkey To modify Craigslist's default, search-results sorting?



Very recently, Craigslist changed the search results sorting on the results page to "relevance". It used to be sorted by "date".



There are radio buttons on the results page, but the "relevance" button is the one that is being defaulted to. Reviewing the source code on the page, there is a line that shows this:


<input type="hidden" name="sort" value="rel">



I think, with my very limited knowledge of coding, that the value="rel" value needs changed to "date". I would like to use Greasemonkey to change the default sorting back to "date".



I think there are plenty of people like me who find the "relevance" sorting very annoying. The way it is now with "relevance", all of the results from a search are scattered by date. I would like the sorting to be how it was, descending, from newest to oldest.



Can this be done with a Greasemonkey script? If so how? Can someone write a script to accomplish this? Is it really difficult to change that one line?



If someone here could help, I would really appreciate it. If there is any more information needed I can provide that(I hope).



I have very limited experience with any coding. I'm just an end user mostly.



Although I'd really like to, I don't think I can learn javascript in a few days, let alone weeks, to be able to write what I need.




4 Answers
4



Changing that <input> won't help. You would need to click the "Newest" button. You would use techniques as described in this answer to do that in the most robust way.


<input>



However, for the Craigslist search pages that I see, for example this one, the sort order buttons are just links that load pages with different query parameters. EG:


?sort=rel&areaID=229&catAbb=sss&query=tools



versus:


?sort=date&areaID=229&catAbb=sss&query=tools



for Relevant versus Newest sorting, respectively.



This means you can use URL rewriting to get the desired sort order and without having to load the whole page twice.



The complete script looks like this:


// ==UserScript==
// @name Craigslist search, switch "Relevant" to "Date" sorting
// @match *://*.craigslist.org/search/*
// @run-at document-start
// @grant none
// ==/UserScript==

//--- Only fire if "sort=rel" is in the query string.

if ( /bsort=relb/.test (window.location.search) )
var newSrch = window.location.search.replace (
/bsort=relb/, "sort=date"
);
var newURL = window.location.protocol + "//"
+ window.location.host
+ window.location.pathname
+ newSrch
+ window.location.hash
;
/*-- replace() puts the good page in the history instead of the
bad page.
*/
window.location.replace (newURL);



For those of you like me that don't know how to use Greasemonkey that well if at all here is the step by step for Firefox 26.0:


26.0



Thank you Brock



I had to remove the + window.locaiton.hash to get it to work in chrome (using tampermonkey instead of greasemonkey). Maybe that'll help someone...



I just added &sort=date at the end of the url in my browser, it worked !!


&sort=date



The original url was:



https://newyork.craigslist.org/search/mnh/crg?query=film&is_paid=all



After adding &sort=date:


&sort=date



https://newyork.craigslist.org/search/mnh/crg?query=film&is_paid=all&sort=date



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ