ZITS: Zetaboards ImprovemenT Script

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

目前為 2017-12-25 提交的版本,檢視 最新版本

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