Silk Road forums

Support => Feature requests => Topic started by: Trojan Sounds on July 03, 2011, 08:35 pm

Title: Sort by 'Ship to'?
Post by: Trojan Sounds on July 03, 2011, 08:35 pm
There are currently 87 listings for weed alone - it would be handy if we could sort the listings by the 'ship to' destinations, ie 'Worldwide; N. America; EU' etc.  Is this possible?
Title: Re: Sort by 'Ship to'?
Post by: Buho on July 04, 2011, 11:47 am
This would be very useful.
Title: Re: Sort by 'Ship to'?
Post by: chewwy on July 04, 2011, 01:55 pm
I think that this post is in the wrong forum, mods must be sleeping ;)
Until they add this feature i found a grease monkey script that does exact what you need. Just as long as the sellers don't name there ship to something crazy like "earth" or "somewhere" should sort the shipto's just fine.

note: i did not make this and to no credit for it
-----------------Code -----------------------------
// ==UserScript==
// @name           Silk Road Filter by country
// @namespace      http://ianxz6zefk72ulzz.onion
// @include        http://ianxz6zefk72ulzz.onion/index.php/silkroad/category/*
// ==/UserScript==

var BODY = document.getElementsByTagName('body')[0];
var productTable = document.getElementById('table1');
var tableBody = productTable.getElementsByTagName("tbody")[0];

var shipToInput;
var shipFromInput;

var products = tableBody.innerHTML;

function filter() {
   var shipTo   = shipToInput.value;
   var shipFrom   = shipFromInput.value;
   
   var filter = new RegExp("<tr.*>\n.*<td>" + shipTo + "<\/td><td>" + shipFrom + "<\/td><td><a href=.*add to cart.*<\/tr>","gi");

   var filteredRows = products.match(filter);
   
   var newTable = "";
   for (var i in filteredRows) {
      newTable += filteredRows;
   }
   
   tableBody.innerHTML = newTable;
}

//Create controls for filtering
var controls = document.createElement("p");

controls.appendChild(document.createTextNode("Ship to: "));
shipToInput = document.createElement("input");
shipToInput.addEventListener("keyup", filter, true)
shipToInput.value = ".*";
controls.appendChild(shipToInput);

controls.appendChild(document.createTextNode(" Ship from: "));
shipFromInput = document.createElement("input");
shipFromInput.addEventListener("keyup", filter, true);
shipFromInput.value = ".*";
controls.appendChild(shipFromInput);
productTable.parentNode.insertBefore(controls, productTable);

//Fetch remaining pages
function addPage(start) {
   GM_xmlhttpRequest({
      method: "GET",
      url: document.location + "/" + (start + 35),
      onload: function(responseDetails) {
         var newProducts = responseDetails.responseText.match(/<tr.*>\n.*<td>.*<\/td><td>.*<\/td><td><a href=.*add to cart.*<\/tr>/gi);
         
         if (newProducts.length > 0) {
            products += newProducts;
            filter();
            addPage(start+35);
         }
      }
   });
}
addPage(0);

------------- end of code -------------------

Title: Re: Sort by 'Ship to'?
Post by: Trojan Sounds on July 04, 2011, 04:31 pm
You're right - apologies, should be in the features board  >:(  Sorry - plus there's loads of threads saying the same on there!

Not sure I want to use a GM script as I use NoScript. 
Title: Re: Sort by 'Ship to'?
Post by: radster on July 05, 2011, 12:56 am
this would be a extremely useful feature - maybe even a permanent just show me sellers shipping from my country in the preferences?
Title: Re: Sort by 'Ship to'?
Post by: podperson on July 09, 2011, 07:18 pm
oh crap, I did not see this thread before I posted the same request. with so many new sellers and products it just makes sense to be able to sort or filter by where the seller will ship to.