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

  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
  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.  
  79. GM_addStyle ( " \
  80. #gmRightSideBar { \
  81. position: fixed; \
  82. top: 0; \
  83. left: 0; \
  84. margin-left: 1ex; \
  85. background-color: rgba(255, 0, 0, 0.5) \
  86. width: 200px; \
  87. z-index: 6666; \
  88. opacity: 0.9; \
  89. height: 100%; \
  90. overflow-y: auto; \
  91. overflow-x: hidden;\
  92. resize:horizontal;\
  93. max-width:300px; \
  94. width:200px; \
  95. } \
  96. #gmRightSideBar p { \
  97. font-size: 80%; \
  98. } \
  99. #gmRightSideBar ul { \
  100. margin: 0ex; \
  101. } \
  102. } \
  103. " );
  104. jQuery(function() {
  105. var page_url = window.location.href;
  106. var base_url = window.location.origin;
  107. if (page_url != "http://starforcerp.com/site/"){
  108. jQuery.get(unsafeWindow.main_url+"home"+"?forceads", "", function (data) {
  109. //jQuery(data).find("#boardmeta").appendTo ("#user_control_panel");
  110. //jQuery(data).find("#ucp_splash").appendTo ("#user_control_panel");
  111.  
  112. jQuery(data).find("#subscriptions").appendTo("#user_control_panel");
  113. jQuery(data).find(".ucp:has(thead tr th:contains(Forum Subscriptions))").appendTo ("#user_control_panel");
  114. jQuery("#subscriptions thead tr th").attr("colspan","2");
  115.  
  116. jQuery("#subscriptions .c_foot form").remove();
  117. jQuery(".ucp:has(thead tr th:contains(Forum Subscriptions)) .c_foot form").remove();
  118. }, "html");
  119. }
  120. });
  121. function addGlobalStyle(css) {
  122. var head, style;
  123. head = document.getElementsByTagName('head')[0];
  124. if (!head) { return; }
  125. style = document.createElement('style');
  126. style.type = 'text/css';
  127. style.innerHTML = css;
  128. head.appendChild(style);
  129. }
  130. addGlobalStyle('iframe {width:100% !important;}');
  131. addGlobalStyle('#subscriptions > thead:nth-child(1) > tr:nth-child(1) > th:nth-child(1) {display:none;}');
  132. addGlobalStyle('#cboxdiv {width:100% !important;}');
  133. 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;}');
  134. function loadjscssfile(filename, filetype){
  135. if (filetype=="js"){ //if filename is a external JavaScript file
  136. var fileref=document.createElement('script')
  137. fileref.setAttribute("type","text/javascript")
  138. fileref.setAttribute("src", filename)
  139. }
  140. else if (filetype=="css"){ //if filename is an external CSS file
  141. var fileref=document.createElement("link")
  142. fileref.setAttribute("rel", "stylesheet")
  143. fileref.setAttribute("type", "text/css")
  144. fileref.setAttribute("href", filename)
  145. }
  146. if (typeof fileref!="undefined")
  147. document.getElementsByTagName("head")[0].appendChild(fileref)
  148. }
  149. loadjscssfile("http://z3.ifrm.com/63/1/0/p481654/Quick_Search.js", "js") //dynamically load and add this .js file
  150. loadjscssfile("http://z3.ifrm.com/63/1/0/p479384/Recent_Updates.js", "js") //dynamically load and add this .js file
  151. if (base_url != "http://starforcerp.com"){
  152. $('.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>");
  153. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5298252/zeta_cookie.js", "js") //dynamically load and add this .js file
  154. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5262218/confirm.js", "js") //dynamically load and add this .js file
  155. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5310358/login_redirect.js", "js") //dynamically load and add this .js file
  156. }
  157. if (base_url != "http://sonic-cyclone.net" && base_url == "http://starforcerp.com"){
  158. $("#fast-reply dd").attr("id","c_post").append("<button id='preview' name='preview' type='button' onclick='Preview(event)' style='margin-right:5px;'>Preview</button>");
  159. }
  160. if (base_url != "http://sonic-cyclone.net" && base_url != "http://starforcerp.com"){
  161. // "Preview in Fast Reply" created by Holysavior of ZBCode and Javascriptin.com
  162. $("#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')"));
  163. $(".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>");
  164. $(".posting #c_post-text,#fast-reply dd textarea").keyup(function(){
  165. var characters = $(this).attr("value").length
  166. var words = $(this).attr("value").split(" ").length
  167. $("#posting_wordchars").html("<b>"+characters+" Characters -- "+words+" Words</b>");
  168. });
  169. }