ZITS: Zetaboards ImprovemenT Script

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

当前为 2015-12-20 提交的版本,查看 最新版本

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