Script to post NewEgg cart on forum
Last response: in Systems
I know this is not directly related to New builds, but since it will mostly be used FOR this section, I guessed it was the best place to post it (could post it in Programming, but not that many people go there
).
So this is a GreaseMonkey script I got from mkey on userscripts.org and I modified it a bit so it would generate code compliant with this forum and would work with the Canadian NewEgg as well.
Hope you guys find this useful, feel free to upgrade it, but I suggest you send the modified code to the original owner on userscripts.org; I did out of fairness.
).So this is a GreaseMonkey script I got from mkey on userscripts.org and I modified it a bit so it would generate code compliant with this forum and would work with the Canadian NewEgg as well.
Hope you guys find this useful, feel free to upgrade it, but I suggest you send the modified code to the original owner on userscripts.org; I did out of fairness.
// ==UserScript==
// @name Newegg to BBcode
// @namespace <a href="http://userscripts.org/scripts/show/87115" rel="nofollow" target="_blank">http://userscripts.org/scripts/show/87115</a>
// @description Converts the newegg shopping cart to a bbcode table ready to be pasted across various boards
// @date 2010-10-01
// @creator mkey
// @include <a href="http://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.com/Shopping/ShoppingCart.aspx?Sub...</a>
// @include <a href="http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Subm...</a>
// ==/UserScript==
var d=document, byId=d.getElementById, create=d.createElement, byClass=d.getElementsByClassName, byTag=d.getElementsByTagName;
(function (){
var item= byClass("cartDescription");
var price= byClass("cartPrice");
var pcs= byClass("cartQty");
var t, t1, t2;
var text = "";
for (var i=1; i<item.length; i++){
t= item[i].getElementsByTagName("a");
t1= price[i].getElementsByTagName("dd");
t2= pcs[i].getElementsByTagName("input");
if (t2.length==0) t2=pcs[i].textContent.trim();
else t2= t2[0].value;
if (t1.length==1) t1= t1[0].textContent;
else if (t1.length==2 && price[i].getElementsByClassName("cartOrig").length>0) t1= t1[1].textContent;
else if (t1.length==2 && price[i].getElementsByClassName("cartUnit").length>0) t1= t1[0].textContent;
else t1= "ERROR";
text += "[*]"+t2+"x [urlExt=http://+t[0].href+"]"+t[0].textContent.trim()+"[/urlExt] ("+t1.trim()+")\n";
}
t= byClass("cartSubtotal cartHeader");
if (!t.length) return;
t= t[0].getElementsByTagName("td");
//text+= "[tr][td][center]-[/center][/td][td][size=3][b][align=right]Subtotal[/align][/b][/size][/td][td][center]-[/center][/td][td][size=3][b]"+t[1].textContent.trim()+"[/b][/size][/td][/tr][/tableb]";
byClass("space")[0].innerHTML= "<td align=\"center\" colspan=\"5\" ><textarea cols=\"160\" rows=\"8\" style=\"font-size:12px;\" onclick=\"this.select();\" >"+text+"</textarea></td>";
})()
More about : script post newegg cart forum
Test:
1x ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner - Bulk - OEM ($18.99)
1x ASRock 880GM-LE AM3 AMD 880G Micro ATX AMD Motherboard ($59.99)
1x PowerColor AX5570 1GBD3-H Radeon HD 5570 1GB 128-bit DDR3 PCI Express 2.1 x16 HDCP Ready Video Card ($64.99)
1x Microsoft Windows 7 Home Premium 64-bit 1-Pack for System Builders - OEM ($174.98)
1x Rosewill Green Series RG430-S12 430W Continuous @40°C, 80 PLUS Certified, Single 12V Rail, Active PFC "Compatible with Core ... ($84.98)
1x AMD Athlon II X4 645 Propus 3.1GHz Socket AM3 95W Quad-Core Desktop Processor ADX645WFGMBOX ($191.98)
Related ressources
- question for newegg shoppers r.e. shopping cart - Forum
- In (My Cart ) at newegg . Ready to order. Last details - Forum
- High-End personal Workstation Guidance - Forum
- ~$1000 first Build, need advice - Forum
- Is there an age requirement to sign for a newegg package? - Forum
I know it still has a few bugs, most of them from the original script. The original script was also providing the total, but when NewEgg "splits" the shopping cart, it would only report the first one it found. I will try to fix those issues
.
So TODO:
List all items in a combo
Give good total
Remove "1x" when there is only 1 item (I think this is superfluous)
.So TODO:
Test of modification #3:
2x ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner - Bulk - OEM ($41.98 )
Rosewill DESTROYER Black Gaming ATX Mid Tower Computer Case, comes with Three Fans-1x Front Blue LED 120mm Fan, 1x Top 120mm ... ($54.99 )
Antec EarthWatts EA650 650W Continuous Power ATX12V Ver.2.2 / EPS12V version 2.91 SLI Certified CrossFire Ready 80 PLUS Certified ... ($89.99 )
SAMSUNG Spinpoint F3 HD502HJ 500GB 7200 RPM SATA 3.0Gb/s 3.5" Internal Hard Drive -Bare Drive ($48.49 )
SAPPHIRE 100312SR Radeon HD 6950 2GB 256-bit GDDR5 PCI Express 2.1 x16 HDCP Ready CrossFireX Support Video Card with Eyefinity ($279.99 )
Intel Core i5-2500K Sandy Bridge 3.3GHz (3.7GHz Turbo Boost) LGA 1155 95W Quad-Core Desktop Processor BX80623I52500K ($219.99 )
Ok, complete redesign of the code. Now each combo item will show up (as distinct item in the list) with the combo URL as their link. I didn't bother putting the number of items back or the price again, but that is my next step. My biggest concern is the way the Canadian site work as a combo could actually be divided (add this combo to your cart for example and go see how it shows up); this is due to the fact that some items are shipping from the US and they divide shipping.
Example:
Antec Nine Hundred Black Steel ATX Mid Tower Computer Case
GIGABYTE GA-880GMA-UD2H AM3 AMD 880G SATA 6Gb/s USB 3.0 HDMI Micro ATX AMD Motherboard
Rosewill DESTROYER Black Gaming ATX Mid Tower Computer Case, comes with Three Fans-1x Front Blue LED 120mm Fan, 1x Top 120mm ...
Rosewill RV2-500 500 W ATX12V v2.2 / EPS12V SLI Ready Power Supply
Kingston HyperX 8GB (2 x 4GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model KHX1600C9D3K2/8GX
AMD Phenom II X6 1090T Black Edition Thuban 3.2GHz Socket AM3 125W Six-Core Desktop Processor HDT90ZFBGRBOX
G.SKILL Phoenix Pro Series FM-25S2S-60GBP2 2.5" 60GB SATA II MLC Internal Solid State Drive (SSD)
Antec EarthWatts EA750 750W Continuous Power ATX12V version 2.3 SLI Certified CrossFire Ready 80 PLUS Certified Active PFC ...
Seagate Barracuda 7200.11 ST31500341AS 1.5TB 7200 RPM SATA 3.0Gb/s 3.5" Internal Hard Drive -Bare Drive
Kingston HyperX Blu 4GB (2 x 2GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model KHX1600C9D3B1K2/4GX
// ==UserScript==
// @name Newegg to BBcode
// @description Converts the newegg shopping cart to a bbcode table ready to be pasted across various boards
// @date 2011-03-10
// @creator Zenthar
// @include <a href="http://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.com/Shopping/ShoppingCart.aspx?Sub...</a>
// @include <a href="http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Subm...</a>
// ==/UserScript==
(function (){
var items= document.getElementsByClassName("cartItem");
var text = "";
for (var i=0; i<items.length; i++){
var url, price, qte, desc, links;
links = items[i].getElementsByTagName("a");
url = links[0].href;
for(var j=0 ; j<links.length ; j++) {
if(links[j].getAttribute("name") == "CART_ITEM")
text += "[*][urlExt=http://+url+]"+links[j].textContent.trim()+"[/urlExt]\n";
}
}
t= document.getElementsByClassName("cartSubtotal cartHeader");
if (!t.length)
return;
t= t[0].getElementsByTagName("td");
document.getElementsByClassName("space")[0].innerHTML= "<td align=\"center\" colspan=\"5\" ><textarea cols=\"160\" rows=\"8\" style=\"font-size:12px;\" onclick=\"this.select();\" >"+text+"</textarea></td>";
})()
Example:
New version, re-added the quantities and it won't show up if only 1.
Example:
Antec Nine Hundred Black Steel ATX Mid Tower Computer Case
GIGABYTE GA-880GMA-UD2H AM3 AMD 880G SATA 6Gb/s USB 3.0 HDMI Micro ATX AMD Motherboard
2x Rosewill DESTROYER Black Gaming ATX Mid Tower Computer Case, comes with Three Fans-1x Front Blue LED 120mm Fan, 1x Top 120mm ...
2x Rosewill RV2-500 500 W ATX12V v2.2 / EPS12V SLI Ready Power Supply
3x Kingston HyperX 8GB (2 x 4GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model KHX1600C9D3K2/8GX
AMD Phenom II X6 1090T Black Edition Thuban 3.2GHz Socket AM3 125W Six-Core Desktop Processor HDT90ZFBGRBOX
G.SKILL Phoenix Pro Series FM-25S2S-60GBP2 2.5" 60GB SATA II MLC Internal Solid State Drive (SSD)
Antec EarthWatts EA750 750W Continuous Power ATX12V version 2.3 SLI Certified CrossFire Ready 80 PLUS Certified Active PFC ...
Seagate Barracuda 7200.11 ST31500341AS 1.5TB 7200 RPM SATA 3.0Gb/s 3.5" Internal Hard Drive -Bare Drive
Kingston HyperX Blu 4GB (2 x 2GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model KHX1600C9D3B1K2/4GX
// ==UserScript==
// @name Newegg to BBcode
// @description Converts the newegg shopping cart to a bbcode table ready to be pasted across various boards
// @date 2011-03-10
// @creator Zenthar
// @include <a href="http://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.com/Shopping/ShoppingCart.aspx?Sub...</a>
// @include <a href="http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Subm...</a>
// ==/UserScript==
(function (){
var items= document.getElementsByClassName("cartItem");
var text = "";
for (var i=0; i<items.length; i++){
var links = items[i].getElementsByTagName("a");
var url = links[0].href;
var qty = "";
{
var candidates = items[i].getElementsByTagName("td");
for(var j=0 ; j<candidates.length ; j++) {
if(candidates[j].getAttribute("class") == "cartQty") {
var inputs = candidates[j].getElementsByTagName("input");
if(inputs.length > 0)
qty = inputs[0].getAttribute("value")
else
qty = candidates[j].textContent.trim();
}
}
}
for(var j=0 ; j<links.length ; j++) {
if(links[j].getAttribute("name") == "CART_ITEM") {
text += "[*]"
if(qty > 1)
text += qty+"x ";
text += "[urlExt=http://+url+]"+links[j].textContent.trim()+"[/urlExt]\n";
}
}
}
var t= document.getElementsByClassName("cartSubtotal cartHeader");
if (!t.length)
return;
t= t[0].getElementsByTagName("td");
document.getElementsByClassName("space")[0].innerHTML= "<td align=\"center\" colspan=\"5\" ><textarea cols=\"160\" rows=\"8\" style=\"font-size:12px;\" onclick=\"this.select();\" >"+text+"</textarea></td>";
})()
Example:
Another version, now with grand total added:
Example:
Antec Nine Hundred Black Steel ATX Mid Tower Computer Case
GIGABYTE GA-880GMA-UD2H AM3 AMD 880G SATA 6Gb/s USB 3.0 HDMI Micro ATX AMD Motherboard
2x Rosewill DESTROYER Black Gaming ATX Mid Tower Computer Case, comes with Three Fans-1x Front Blue LED 120mm Fan, 1x Top 120mm ...
2x Rosewill RV2-500 500 W ATX12V v2.2 / EPS12V SLI Ready Power Supply
3x Kingston HyperX 8GB (2 x 4GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model KHX1600C9D3K2/8GX
AMD Phenom II X6 1090T Black Edition Thuban 3.2GHz Socket AM3 125W Six-Core Desktop Processor HDT90ZFBGRBOX
G.SKILL Phoenix Pro Series FM-25S2S-60GBP2 2.5" 60GB SATA II MLC Internal Solid State Drive (SSD)
Antec EarthWatts EA750 750W Continuous Power ATX12V version 2.3 SLI Certified CrossFire Ready 80 PLUS Certified Active PFC ...
Seagate Barracuda 7200.11 ST31500341AS 1.5TB 7200 RPM SATA 3.0Gb/s 3.5" Internal Hard Drive -Bare Drive
Kingston HyperX Blu 4GB (2 x 2GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model KHX1600C9D3B1K2/4GX
TOTAL: $1,310.24
// ==UserScript==
// @name Newegg to BBcode
// @description Converts the newegg shopping cart to a bbcode table ready to be pasted across various boards
// @date 2011-03-10
// @creator Zenthar
// @include <a href="http://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.com/Shopping/ShoppingCart.aspx?Sub...</a>
// @include <a href="http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Submit=view" rel="nofollow" target="_blank">http://secure.newegg.ca/Shopping/ShoppingCart.aspx?Subm...</a>
// ==/UserScript==
(function (){
var items= document.getElementsByClassName("cartItem");
var text = "";
for (var i=0; i<items.length; i++){
var links = items[i].getElementsByTagName("a");
var url = links[0].href;
var qty = "";
{
var candidates = items[i].getElementsByTagName("td");
for(var j=0 ; j<candidates.length ; j++) {
if(candidates[j].getAttribute("class") == "cartQty") {
var inputs = candidates[j].getElementsByTagName("input");
if(inputs.length > 0)
qty = inputs[0].getAttribute("value")
else
qty = candidates[j].textContent.trim();
}
}
}
for(var j=0 ; j<links.length ; j++) {
if(links[j].getAttribute("name") == "CART_ITEM") {
text += "[*]"
if(qty > 1)
text += qty+"x ";
text += "[urlExt=http://+url+]"+links[j].textContent.trim()+"[/urlExt]\n";
}
}
}
var grandTotal = document.getElementsByClassName("cartTotal cartHeader")[0];
grandTotal = grandTotal.getElementsByTagName("td")[1].textContent.trim();//Always 2nd element
text += "TOTAL: [u][b]"+grandTotal+"[/b][/u]";
var t= document.getElementsByClassName("cartSubtotal cartHeader");
if (!t.length)
return;
t= t[0].getElementsByTagName("td");
document.getElementsByClassName("space")[0].innerHTML= "<td align=\"center\" colspan=\"5\" ><textarea cols=\"160\" rows=\"8\" style=\"font-size:12px;\" onclick=\"this.select();\" >"+text+"</textarea></td>";
})()
Example:
TOTAL: $1,310.24
Excellent work, thanks.
So how do we install this script? I went to the userscripts.org location to install the original one.
I tried to copy it out of your post and save it as a user.js file, but that didn't seem to work.
This is the first time I've tried greasemonkey, am I missing something?
Oh, and if you're still working on it, I really liked the individual prices listed in Version 3.
So how do we install this script? I went to the userscripts.org location to install the original one.
I tried to copy it out of your post and save it as a user.js file, but that didn't seem to work.
This is the first time I've tried greasemonkey, am I missing something?
Oh, and if you're still working on it, I really liked the individual prices listed in Version 3.
CopaMundial said:
Excellent work, thanks.So how do we install this script? I went to the userscripts.org location to install the original one.
I tried to copy it out of your post and save it as a user.js file, but that didn't seem to work.
This is the first time I've tried greasemonkey, am I missing something?
Oh, and if you're still working on it, I really liked the individual prices listed in Version 3.
Off the top of my head, if you have already got the original installed:
Click on the grey "bbcode" button above the post.
Select and copy the appropriate text, or all of it.
Go to manage user scripts in Greasemonkey and select edit.
Delete whatever is already there and replace it with what you copied.
Compare carefully the post to what you pasted. Make sure nothing gets cut off or such (did in mine). Save the script.
To simplify everyone's life, I just uploaded the script to userscirpts.org so you just have to press the "Install" button
Link
Link
Test!
2x ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner - Bulk - OEM
PowerColor AX5570 1GBD3-H Radeon HD 5570 1GB 128-bit DDR3 PCI Express 2.1 x16 HDCP Ready Video Card
Microsoft Windows 7 Home Premium 64-bit 1-Pack for System Builders - OEM
Western Digital Caviar Green WD20EARS 2TB SATA 3.0Gb/s 3.5" Internal Hard Drive -Bare Drive
Rosewill Green Series RG430-S12 430W Continuous @40°C, 80 PLUS Certified, Single 12V Rail, Active PFC "Compatible with Core ...
Rosewill DESTROYER Black Gaming ATX Mid Tower Computer Case, comes with Three Fans-1x Front Blue LED 120mm Fan, 1x Top 120mm ...
AMD Athlon II X4 645 Propus 3.1GHz Socket AM3 95W Quad-Core Desktop Processor ADX645WFGMBOX
Patriot Signature 8GB (2 x 4GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory with heatshield Model PSD38G1600KH
TOTAL: $554.91
TOTAL: $554.91
Nice work. I was already using the NewEgg hidden price revealer: http://userscripts.org/scripts/show/94901
This is better.
CORSAIR XMS3 4GB (2 x 2GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model CMX4GX3M2A1600C9
GIGABYTE GA-H67A-UD3H-B3 LGA 1155 Intel H67 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i3-2120 Sandy Bridge 3.3GHz LGA 1155 65W Dual-Core Desktop Processor BX80623I32120
Microsoft Windows 7 Home Premium 64-bit 1-Pack for System Builders - OEM
Seagate Barracuda 7200.12 ST3500418AS 500GB 7200 RPM SATA 3.0Gb/s 3.5" Internal Hard Drive -Bare Drive
TOTAL: $474.95
This is better.
TOTAL: $474.95
I tweaked it quick to make a Chrome friendly version, chrome doesnt require an extension to run scripts like greasemonkey, they appear to have built it in
Chrome version
Test to confirm it works:
ATI 100-505604 FirePro V7800 2GB 256-bit GDDR5 PCI Express 2.0 x16 CrossFire Supported Workstation Video Card
ABS TIGAS Full Black Anodized Aluminum Super Full Tower Computer Case, Front Access 10x Hot-Swappable SATA/SAS HDD with independent ...
Intel Core i7-950 Bloomfield 3.06GHz LGA 1366 130W Quad-Core Processor BX80601950
ASUS Sabertooth X58 LGA 1366 Intel X58 SATA 6Gb/s USB 3.0 ATX Intel Motherboard
G.SKILL Ripjaws Series 12GB (3 x 4GB) 240-Pin DDR3 SDRAM DDR3 1600 (PC3 12800) Desktop Memory Model F3-12800CL9T-12GBRL
Thermaltake Black Widow W0319RU 850W ATX 12V v2.3, EPS 12V v2.91 CrossFire Certified 80 PLUS BRONZE Certified Modular Active ...
Seagate Barracuda LP ST32000542AS 2TB 5900 RPM SATA 3.0Gb/s 3.5" Hard Drive -Bare Drive
LITE-ON 24X DVD Writer Black SATA Model iHAS424-98 LightScribe Support
Antec TruePower Quattro Series TPQ-1200 OC (Fan Control Knob/+12V Voltage Control Knob) 1200W Continuous Power ATX12V v2.3 ...
Antec Lanboy air Blue Black / Blue Computer Modular Case
TOTAL: $2,122.97
Chrome version
Test to confirm it works:
TOTAL: $2,122.97
TOTAL: $325.30
This is a test xD
A client build, already have the memory and hard drive.
EDIT : You sir are a genius !
Works like a charm ! Thanks for your hard work !
hunter315 said:
I tweaked it quick to make a Chrome friendly version, chrome doesnt require an extension to run scripts like greasemonkey, they appear to have built it in Chrome versionI forgot about that feature
I'll have to see if I can get that running again under NoScript. Related ressources:
- Forum*How To Ask For New Build Advice*
- ForumCure cancer w/ F@H.
- Forum*How To Ask For New Build Advice*
- ForumCure cancer w/ F@H.
- Forum*How To Ask For New Build Advice*
- ForumCure cancer w/ F@H.
- ForumNewEgg status stuck on "Processing" & my opinion about VerifiedByVisa
- ForumNewegg and Black Friday
- Forum$1,500 build. rate please
- Forumproblems with newegg ?
- ForumAdvice on my 1st NewEgg GrOUndup AMD build.
- ForumNewegg no more.
- ForumNewEgg Boycott
- ForumFinal Build Under $900
- Forum$1355.XX Gaming PC - Ordering ASAP
- More resources
Read discussions in other Systems categories
!