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-22 提交的版本,查看 最新版本

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