lash's Zetaboards Improvement Script

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

当前为 2015-09-18 提交的版本,查看 最新版本

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