Homosuck

Makes Homestuck suck less

  1. // ==UserScript==
  2. // @name Homosuck
  3. // @namespace pendevin
  4. // @description Makes Homestuck suck less
  5. // @include http://www.mspaintadventures.com/*
  6. // @include http://mspaintadventures.com/*
  7. // @version 1
  8. // ==/UserScript==
  9.  
  10. //does shit with xpaths i guess
  11. var XPATH={
  12. //returns an ordered array of objects matching the xpath expression
  13. //if context is undefined, defaults to the document
  14. //returns an empty array if there are no matches
  15. get:function(expression,context){
  16. //optional variable, yo
  17. if(context==undefined)
  18. context=document;
  19. var xpathResult=document.evaluate(expression,context,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  20. var result=[];
  21. for(var i=0;i<xpathResult.snapshotLength;i++)
  22. result.push(xpathResult.snapshotItem(i));
  23. return result.length>0?result:[];
  24. },
  25.  
  26. //counts all the elements that match the xpath expression
  27. //if context is undefined, defaults to the document
  28. count:function(expression,context){
  29. //optional variable, yo
  30. if(context==undefined)
  31. context=document;
  32. expression='count('+expression+')';
  33. var xpathResult=document.evaluate(expression,context,null,XPathResult.NUMBER_TYPE,null);
  34. return xpathResult.numberValue;
  35. }
  36. }
  37.  
  38. function simulateClick(element){
  39. var evt=document.createEvent("MouseEvents");
  40. evt.initMouseEvent("click",true,true,window,1,0,0,0,0,false,false,false,false,0,null);
  41. element.dispatchEvent(evt);
  42. }
  43.  
  44. var title=XPATH.get('//td[@bgcolor="#EEEEEE"]/table/tbody/tr/td[2]/center/p')[0];
  45. var images=XPATH.get('//td[@bgcolor="#EEEEEE"]/center')[0];
  46. var text=XPATH.get('//td[@bgcolor="#EEEEEE"]/table/tbody/tr/td[1]/center')[0];
  47. var banner=XPATH.get('//td[@background="images/bannerframe.png"]/center/a')[0];
  48. var news=XPATH.get('//table[@width="676"]/tbody/tr/td/table')[0];
  49. var searchLink=XPATH.get('//font[@size="1"]/b/a[6]')[0];
  50. var backLink=XPATH.get('//span[@style="font-size: 10px;"]/b[2]/a')[0];
  51. var latest=[
  52. XPATH.get('//table[@width="255"]/tbody/tr[2]/td/center/img[2]')[0],
  53. XPATH.get('//table[@width="255"]/tbody/tr[3]/td/table/tbody/tr/td/p')[0],
  54. XPATH.get('//table[@width="255"]/tbody/tr[4]/td/center/font')[0],
  55. XPATH.get('//table[@width="255"]/tbody/tr[4]/td/center[2]/span')[0]
  56. ];
  57. var command=XPATH.get('//table/tbody/tr/td/font//a[contains(@href,"?s=6&p=")]')[0];
  58.  
  59. if(text){
  60. if(text.firstElementChild.textContent=='\n \n \n')
  61. text.firstElementChild.style.display='none';
  62. text.firstElementChild.style.maxHeight='450px';
  63. text.firstElementChild.style.overflowY='auto';
  64. if(text.children[1]){
  65. text.children[1].style.maxHeight='450px';
  66. text.children[1].style.overflowY='auto';
  67. }
  68. }
  69.  
  70.  
  71. for(var i=0;i<document.getElementsByClassName('spoiler').length;i++){
  72. //get pesterlog
  73. var pesterlog=document.getElementsByClassName('spoiler')[i];
  74. var log=pesterlog.getElementsByTagName('p')[0];
  75.  
  76. //apply scrolling
  77. pesterlog.getElementsByTagName("table")[0].style.width='100%';
  78. log.style.maxHeight='402px';
  79. log.style.margin='10px 8px 14px 18px';
  80. log.style.overflowY='scroll';
  81.  
  82. //put in the chat log type
  83. var logTitle=document.createElement('p');
  84. logTitle.textContent=pesterlog.previousSibling.textContent.substring(5);
  85. logTitle.style.fontWeight='bold';
  86. logTitle.style.fontFamily='courier,monospace';
  87. logTitle.style.margin='2px 18px 6px 11px';
  88. log.parentNode.insertBefore(logTitle,log);
  89.  
  90. pesterlog.previousSibling.style.display='none';
  91. pesterlog.style.display='block';
  92. pesterlog.firstChild.firstChild.style.display='none';
  93. }
  94.  
  95. //shortcuts
  96. document.addEventListener('keypress',function keyPress(e){
  97. if(e.ctrlKey&&e.keyCode==37)
  98. simulateClick(backLink);
  99. else if(command&&e.ctrlKey&&e.keyCode==39)
  100. simulateClick(command);
  101. },true);