ZITS: Zetaboards ImprovemenT Script

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

当前为 2016-09-29 提交的版本,查看 最新版本

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