lash's Zetaboards Improvement Script

An all-in-one script that works on pretty much every Zetaboards forum, adding a sidebar and other code.

当前为 2015-09-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name lash's Zetaboards Improvement Script
  3. // @namespace zetaboards-improvement
  4. // @description An all-in-one script that works on pretty much every Zetaboards forum, adding a sidebar and other code.
  5. // @include http://stackoverflow.com/questions/14722302/*
  6. // @include http://starforcerp.com/*
  7. // @include starforcerp.com/*
  8. // @include http://*.zetaboards.com/*
  9. // @include http://sonic-cyclone.net/*
  10. // @version 8
  11. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  12. // @grant GM_addStyle
  13. // ==/UserScript==
  14. $('.topic-buttons').prepend(" <a href='"+$('#foot_links a:contains(Track Topic)').attr('href')+"'><img src='http://z5.ifrm.com/9054/18/0/f5307276/track_topic.png' alt='track topic' /></a>");
  15.  
  16. $("body").append ( ' \
  17. <div id="gmRightSideBar"> \
  18. <p>F9 toggles visibility</p> \ \
  19. <table class="cat_head" id="collapsed" style="border-collapse:collapse; margin:0px; padding:0px;"> \
  20. <tbody><tr><td><h2><span class="collapse" style="float:initial;"><center>Chat (click to toggle)</center></span></h2></td></tr></tbody></table> \
  21. <table style="display: table; margin:0px; padding: 0px;" cellpadding="0" cellspacing="0"> \
  22. <tbody><tr><td style="width:100%;" valign="top"> \
  23. <div id="chat"> \
  24. </div> \
  25. </td></tr></tbody></table> \
  26. <table class="cat_head" id="collapsed" style="border-collapse:collapse; margin: 0px; padding:0px;"> \
  27. <tbody><tr><td><h2><span class="collapse" style="float:initial;"><center>Subscriptions (click to toggle)</center></span></h2></td></tr></tbody></table> \
  28. <table style="display: table; padding: 0px; margin:0px;" cellpadding="0" cellspacing="0"> \
  29. <tbody><tr><td style="width:100%;" valign="top"> \
  30. <div id="user_control_panel"> \
  31. </div> \
  32. </td></tr></tbody></table> \
  33. </div> \
  34. ' );
  35. $('#cboxdiv').remove().clone().appendTo('#chat');
  36. //-- Fade panel when not in use
  37. var kbShortcutFired = false;
  38. var rightSideBar = $('#gmRightSideBar');
  39. rightSideBar.hover (
  40. function () {
  41. $(this).stop (true, false).fadeTo (50, 1 );
  42. kbShortcutFired = false;
  43. },
  44. function () {
  45. if ( ! kbShortcutFired ) {
  46. $(this).stop (true, false).fadeTo (900, 0.1);
  47. }
  48. kbShortcutFired = false;
  49. }
  50. );
  51. rightSideBar.fadeTo (2900, 0.1);
  52.  
  53. //-- Keyboard shortcut to show/hide our sidebar
  54. $(window).keydown (keyboardShortcutHandler);
  55.  
  56. function keyboardShortcutHandler (zEvent) {
  57. //--- On F9, Toggle our panel's visibility
  58. if (zEvent.which == 120) { // F9
  59. kbShortcutFired = true;
  60.  
  61. if (rightSideBar.is (":visible") ) {
  62. rightSideBar.stop (true, false).hide ();
  63. }
  64. else {
  65. //-- Reappear opaque to start
  66. rightSideBar.stop (true, false).show ();
  67. rightSideBar.fadeTo (0, 1);
  68. rightSideBar.fadeTo (2900, 0.1);
  69. }
  70.  
  71. zEvent.preventDefault ();
  72. zEvent.stopPropagation ();
  73. return false;
  74. }
  75. }
  76.  
  77. GM_addStyle ( " \
  78. #gmRightSideBar { \
  79. position: fixed; \
  80. top: 0; \
  81. left: 0; \
  82. margin-left: 1ex; \
  83. background-color: rgba(255, 0, 0, 0.5) \
  84. width: 200px; \
  85. z-index: 6666; \
  86. opacity: 0.9; \
  87. height: 100%; \
  88. overflow-y: auto; \
  89. overflow-x: hidden;\
  90. resize:horizontal;\
  91. max-width:300px; \
  92. width:200px; \
  93. } \
  94. #gmRightSideBar p { \
  95. font-size: 80%; \
  96. } \
  97. #gmRightSideBar ul { \
  98. margin: 0ex; \
  99. } \
  100. } \
  101. " );
  102. jQuery(function() {
  103. var base_url = window.location.origin;
  104. jQuery.get(base_url+"/home"+"?forceads", "", function (data) {
  105. //jQuery(data).find("#boardmeta").appendTo ("#user_control_panel");
  106. //jQuery(data).find("#ucp_splash").appendTo ("#user_control_panel");
  107.  
  108. jQuery(data).find("#subscriptions").appendTo("#user_control_panel");
  109. jQuery(data).find(".ucp:has(thead tr th:contains(Forum Subscriptions))").appendTo ("#user_control_panel");
  110. jQuery("#subscriptions thead tr th").attr("colspan","2");
  111.  
  112. jQuery("#subscriptions .c_foot form").remove();
  113. jQuery(".ucp:has(thead tr th:contains(Forum Subscriptions)) .c_foot form").remove();
  114. }, "html");
  115.  
  116. });
  117. function addGlobalStyle(css) {
  118. var head, style;
  119. head = document.getElementsByTagName('head')[0];
  120. if (!head) { return; }
  121. style = document.createElement('style');
  122. style.type = 'text/css';
  123. style.innerHTML = css;
  124. head.appendChild(style);
  125. }
  126. addGlobalStyle('iframe {width:100% !important;}');
  127. addGlobalStyle('#subscriptions > thead:nth-child(1) > tr:nth-child(1) > th:nth-child(1) {display:none;}');
  128. addGlobalStyle('#cboxdiv {width:100% !important;}');
  129. addGlobalStyle('table#subscriptions tbody > tr th:nth-child(3), table#subscriptions tbody > tr th:nth-child(4), table#subscriptions tbody > tr th:nth-child(2), table#subscriptions tr[class*="row"] td:nth-child(3), table#subscriptions tr[class*="row"] td:nth-child(4), table#subscriptions tr[class*="row"] td:nth-child(2),table#subscriptions tr[class*="row"] td:nth-child(6), table#subscriptions tbody > tr th:nth-child(6) {display: none;}');