ZITS: Zetaboards ImprovemenT Script

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

  1. // ==UserScript==
  2. // @name ZITS: Zetaboards ImprovemenT Script
  3. // @namespace zetaboards-improvement
  4. // @homepage https://greasyfork.org/en/scripts/12509-lash-s-zetaboards-improvement-script/
  5. // @icon http://i57.tinypic.com/2m4ruoz.png
  6. // @description An all-in-one script that works on pretty much every Zetaboards forum, adding a sidebar and other code.
  7. // @include */index/
  8. // @include */post/*
  9. // @include */forum/*
  10. // @include */topic/*
  11. // @exclude */home/
  12. // @version 15.5
  13. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  14. // @grant GM_addStyle
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // ==/UserScript==
  18. var visible = GM_getValue("sidebar");
  19. var base_url = window.location.origin;
  20. $("body").append ( ' \
  21. <div id="gmRightSideBar"> \
  22. <p>F9 toggles visibility</p> \ \
  23. <table class="cat_head" id="collapsed" style="border-collapse:collapse; margin:0px; padding:0px;"> \
  24. <tbody><tr><td><h2><span class="collapse" style="float:initial;"><center>Chat (click to toggle)</center></span></h2></td></tr></tbody></table> \
  25. <table style="display: table; margin:0px; padding: 0px;" cellpadding="0" cellspacing="0"> \
  26. <tbody><tr><td style="width:100%;" valign="top"> \
  27. <div id="chat"> \
  28. </div> \
  29. </td></tr></tbody></table> \
  30. <table class="cat_head" id="collapsed" style="border-collapse:collapse; margin: 0px; padding:0px;"> \
  31. <tbody><tr><td><h2><span class="collapse" style="float:initial;"><center>Subscriptions (click to toggle)</center></span></h2></td></tr></tbody></table> \
  32. <table style="display: table; padding: 0px; margin:0px;" cellpadding="0" cellspacing="0"> \
  33. <tbody><tr><td style="width:100%;" valign="top"> \
  34. <div id="user_control_panel"> \
  35. </div> \
  36. </td></tr></tbody></table> \
  37. </div> \
  38. ' );
  39. $('#cboxdiv').remove().clone().appendTo('#chat');
  40. //-- Fade panel when not in use
  41. var kbShortcutFired = false;
  42. var rightSideBar = $('#gmRightSideBar');
  43. rightSideBar.hover (
  44. function () {
  45. $(this).stop (true, false).fadeTo (50, 1 );
  46. kbShortcutFired = false;
  47. },
  48. function () {
  49. if ( ! kbShortcutFired ) {
  50. $(this).stop (true, false).fadeTo (900, 0.1);
  51. }
  52. kbShortcutFired = false;
  53. }
  54. );
  55. rightSideBar.fadeTo (2900, 0.1);
  56.  
  57. //-- Keyboard shortcut to show/hide our sidebar
  58. $(window).keydown (keyboardShortcutHandler);
  59.  
  60. function keyboardShortcutHandler (zEvent) {
  61. //--- On F9, Toggle our panel's visibility
  62. if (zEvent.which == 120) { // F9
  63. kbShortcutFired = true;
  64.  
  65. if (rightSideBar.is (":visible") ) {
  66. GM_setValue("sidebar", "false");
  67. rightSideBar.stop (true, false).hide ();
  68. }
  69. else {
  70. //-- Reappear opaque to start
  71. GM_setValue("sidebar", "true");
  72. rightSideBar.stop (true, false).show ();
  73. rightSideBar.fadeTo (0, 1);
  74. rightSideBar.fadeTo (2900, 0.1);
  75. }
  76.  
  77. zEvent.preventDefault ();
  78. zEvent.stopPropagation ();
  79. return false;
  80. }
  81. }
  82. var window_width = $(window).width();
  83. var page_width = document.getElementById("wrap").clientWidth;
  84. if (page_width == 800 && window_width >= 1200){
  85. GM_addStyle ( " \
  86. #install-area { \
  87. display: none; \
  88. } \
  89. #gmRightSideBar { \
  90. position: fixed; \
  91. top: 0; \
  92. left: 0; \
  93. margin-left: 1ex; \
  94. background-color: rgba(255, 0, 0, 0.5) \
  95. width: 300px; \
  96. z-index: 6666; \
  97. opacity: 0.9; \
  98. height: 100%; \
  99. overflow-y: auto; \
  100. overflow-x: hidden;\
  101. resize:horizontal;\
  102. max-width:300px; \
  103. width:300px; \
  104. } \
  105. #gmRightSideBar p { \
  106. font-size: 80%; \
  107. } \
  108. #gmRightSideBar ul { \
  109. margin: 0ex; \
  110. } \
  111. } \
  112. " );
  113. }
  114. if (page_width != 800){
  115. GM_addStyle ( " \
  116. #install-area { \
  117. display: none; \
  118. } \
  119. #gmRightSideBar { \
  120. position: fixed; \
  121. top: 0; \
  122. left: 0; \
  123. margin-left: 1ex; \
  124. background-color: rgba(255, 0, 0, 0.5) \
  125. width: 200px; \
  126. z-index: 6666; \
  127. opacity: 0.9; \
  128. height: 100%; \
  129. overflow-y: auto; \
  130. overflow-x: hidden;\
  131. resize:horizontal;\
  132. max-width:300px; \
  133. width:200px; \
  134. } \
  135. #gmRightSideBar p { \
  136. font-size: 80%; \
  137. } \
  138. #gmRightSideBar ul { \
  139. margin: 0ex; \
  140. } \
  141. } \
  142. " );
  143. }
  144. if (visible == "false"){
  145. rightSideBar.stop (true, false).hide ();
  146. }
  147. jQuery(function() {
  148. var page_url = window.location.href;
  149. var base_url = window.location.origin;
  150. if (page_url != "http://starforcerp.com/site/"){
  151. jQuery.get(unsafeWindow.main_url+"home"+"?forceads", "", function (data) {
  152. //jQuery(data).find("#boardmeta").appendTo ("#user_control_panel");
  153. //jQuery(data).find("#ucp_splash").appendTo ("#user_control_panel");
  154.  
  155. jQuery(data).find("#subscriptions").appendTo("#user_control_panel");
  156. jQuery(data).find(".ucp:has(thead tr th:contains(Forum Subscriptions))").appendTo ("#user_control_panel");
  157. jQuery("#subscriptions thead tr th").attr("colspan","2");
  158.  
  159. jQuery("#subscriptions .c_foot form").remove();
  160. jQuery(".ucp:has(thead tr th:contains(Forum Subscriptions)) .c_foot form").remove();
  161. }, "html");
  162. }
  163. });
  164. function addGlobalStyle(css) {
  165. var head, style;
  166. head = document.getElementsByTagName('head')[0];
  167. if (!head) { return; }
  168. style = document.createElement('style');
  169. style.type = 'text/css';
  170. style.innerHTML = css;
  171. head.appendChild(style);
  172. }
  173. addGlobalStyle('iframe {width:100% !important;}');
  174. addGlobalStyle('#subscriptions > thead:nth-child(1) > tr:nth-child(1) > th:nth-child(1) {display:none;}');
  175. addGlobalStyle('#cboxdiv {width:100% !important;}');
  176. 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;}');
  177. function loadjscssfile(filename, filetype){
  178. if (filetype=="js"){ //if filename is a external JavaScript file
  179. var fileref=document.createElement('script')
  180. fileref.setAttribute("type","text/javascript")
  181. fileref.setAttribute("src", filename)
  182. }
  183. else if (filetype=="css"){ //if filename is an external CSS file
  184. var fileref=document.createElement("link")
  185. fileref.setAttribute("rel", "stylesheet")
  186. fileref.setAttribute("type", "text/css")
  187. fileref.setAttribute("href", filename)
  188. }
  189. if (typeof fileref!="undefined")
  190. document.getElementsByTagName("head")[0].appendChild(fileref)
  191. }
  192. loadjscssfile("http://z3.ifrm.com/63/1/0/p479384/Recent_Updates.js", "js") //dynamically load and add this .js file
  193. if (base_url != "http://starforcerp.com"){
  194. loadjscssfile("http://z3.ifrm.com/63/1/0/p481654/Quick_Search.js", "js") //dynamically load and add this .js file
  195. $('.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>");
  196. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5298252/zeta_cookie.js", "js") //dynamically load and add this .js file
  197. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5262218/confirm.js", "js") //dynamically load and add this .js file
  198. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5310358/login_redirect.js", "js") //dynamically load and add this .js file
  199. }
  200. if (base_url != "http://sonic-cyclone.net" && base_url == "http://starforcerp.com"){
  201. $("#fast-reply dd").attr("id","c_post").append("<button id='preview' name='preview' type='button' onclick='Preview(event)' style='margin-right:5px;'>Preview</button>");
  202. }
  203. if (base_url != "http://sonic-cyclone.net" && base_url != "http://starforcerp.com"){
  204. // "Preview in Fast Reply" created by Holysavior of ZBCode and Javascriptin.com
  205. $("#fast-reply dd").attr("id","c_post").append("<button id='preview' name='preview' type='button' onclick='Preview(event)' style='margin-right:5px;'>Preview</button>");$("#preview").after($("#fast-reply button:contains('Full Reply Screen')"));
  206. var sel = document.getElementById('postlengthchar');
  207. if (sel === null) {
  208. $(".posting #btn_preview,.posting .btn_normal,#fast-reply #btn_preview,#fast-reply .btn_normal").after("<br /><span id='posting_wordchars'><b>0 Characters || 0 Words</b></span>");
  209. $(".posting #c_post-text,#fast-reply dd textarea").keyup(function(){
  210. var characters = $(this).attr("value").length;
  211. var words = $(this).attr("value").split(" ").length;
  212. $("#posting_wordchars").html("<b>"+characters+" Characters || "+words+" Words</b>");
  213. });
  214. }
  215. }