Newegg Screen Dimensions

Shows the screen dimensions next to the diagonal size

  1. // ==UserScript==
  2. // @name Newegg Screen Dimensions
  3. // @namespace http://mailerdaemon.home.comcast.net
  4. // @description Shows the screen dimensions next to the diagonal size
  5. // @include http://www.newegg.com/Product/Product.aspx?*
  6. // @version 0.1
  7. // ==/UserScript==
  8.  
  9. size = $X("//div[@id='pcraSpecs']//td[position()=1 and text()='Screen Size']/following-sibling::td/text()");
  10. dim = $X("//div[@id='pcraSpecs']//td[position()=1 and text()='Maximum Resolution']/following-sibling::td/text()");
  11.  
  12. if(size && dim)
  13. {
  14. result = /[\s]*([\d]+)[\s]+x[\s]+([\d]+)[\s]*/.exec(dim.data);
  15. x = Number(result[1]);
  16. y = Number(result[2]);
  17. d = Number(size.data.slice(0, -1));
  18. ps = d / Math.sqrt(x * x + y * y);
  19. size.data = size.data + " ( " + String(ps * x).slice(0,5) +'" x ' + String(ps * y).slice(0,5) + '" )';
  20. pp = $X("//div[@id='pcraSpecs']//td[position()=1 and text()='Pixel Pitch']/following-sibling::td/text()");
  21. if(pp)
  22. pp.data += ' [' + String(ps / 0.0393700787402).substring(0, 5) + 'mm]';
  23. //else
  24. size.data += ' at ' + String(ps / 0.0393700787402).substring(0, 5) + 'mm';
  25. }
  26.  
  27. function $X(_xpath, node){return document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);}
  28. /*
  29. function $Y(_xpath, node){return document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);}
  30. function $Z(_xpath, func, node, payload){
  31. var res = document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  32. var i, j;
  33. for (i = j = 0; link = res.snapshotItem(i); ++i)
  34. j += func(link, i, payload);
  35. return j;
  36. }
  37. function insertAfter(insert, after){return after.parentNode.insertBefore(insert, after.nextSibling);}
  38. function insertBefore(insert, before){return before.parentNode.insertBefore(insert, before);}
  39. */