// ==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.3 // @grant none // @downloadURL none // ==/UserScript== 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, i,cart,item,img,IMG,a,txt, items=Array(),mir=Array(); table=make('table'); table.border=1; table.appendChild(make('tbody')); tbody=table.childNodes[0]; tr=make('tr'); 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('There are '+mir.length+' Mail-in Rebates: ')); for(i=0;i0?2:4); td.appendChild(a) tr.appendChild(td); tbody.appendChild(tr); div=make('div'); div.appendChild(table); 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=div.innerHTML; this.document.getElementById('preview').appendChild(div); },false); },false); holder.snapshotItem(1).appendChild(btn); }