// ==UserScript== // @name Newegg cart to post converter for eggxpert.com // @namespace http://userscripts.org/users/62850 // @description Converts the cart in to postable html that has been patched for the forums // @include http://secure.newegg.com/Shopping/ShoppingCart.aspx* // @include http://secure.newegg.ca/Shopping/ShoppingCart.aspx* // @version 2.6 // @grant none // @downloadURL none // ==/UserScript== function addCommas(nStr){//http://www.mredkj.com/javascript/nfbasic.html nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function findEle(target,i,e){ if(i==9) return document.evaluate(target, e?e:document, null, i, null).singleNodeValue; else return document.evaluate(target, e?e:document, null, i, null); } function make(tag){ return document.createElement(tag); } var holder=findEle('.//table[@class="head"]/tbody/tr[@class="tool-bar"]/td',6,false),btn; if(holder.snapshotLength==2){ btn=make('a'); btn.className='button button-mini button-tertiary'; btn.href="javascript:return false;"; btn.textContent='Generate HTML Code'; btn.title="HTML code for posting on forums"; btn.addEventListener('click',function(){ var table,tbody,tr,td,div,img, i,cart,item,val,a,txt,IMG, items=Array(),mir=Array(); table=make('table'); table.border=1; table.appendChild(make('tbody')); tbody=table.childNodes[0]; tr=make('tr'); tr.align="center"; td=make('th'); td.textContent='Item'; td.setAttribute('colspan',2); tr.appendChild(td); td=make('th'); td.textContent='Quantity'; tr.appendChild(td); td=make('th'); td.textContent='Price'; tr.appendChild(td); tbody.appendChild(tr); cart=findEle('.//table[@class="shipping-group"]/tbody/tr',6); for(i=0;i0){ td=make('td'); td.setAttribute('colspan',2); td.appendChild(document.createTextNode(mir.length>1?'There are '+mir.length+' Mail-in Rebates: ':'There is '+mir.length+' Mail-in Rebate: ')); for(i=0;i0?2:4); td.appendChild(a) tr.appendChild(td); tbody.appendChild(tr); window.open('data:text/html;charset=utf-8,'+encodeURIComponent('HTML Code to Post'+ 'If you would like to readable HTML code, paste it in the Tabifier.
'+ 'Copy & Paste the above code.
'+ '
Preview'+ '
')).addEventListener('load',function(){ this.document.getElementById('txtBox').value=table.outerHTML; this.document.getElementById('preview').appendChild(table); },false); },false); holder.snapshotItem(1).appendChild(btn); }