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. // @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://sonic-cyclone.net/*
  12. // @version 10
  13. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  14. // @grant GM_addStyle
  15. // ==/UserScript==
  16. var base_url = window.location.origin;
  17. $('.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>");
  18.  
  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. rightSideBar.stop (true, false).hide ();
  66. }
  67. else {
  68. //-- Reappear opaque to start
  69. rightSideBar.stop (true, false).show ();
  70. rightSideBar.fadeTo (0, 1);
  71. rightSideBar.fadeTo (2900, 0.1);
  72. }
  73.  
  74. zEvent.preventDefault ();
  75. zEvent.stopPropagation ();
  76. return false;
  77. }
  78. }
  79.  
  80. GM_addStyle ( " \
  81. #gmRightSideBar { \
  82. position: fixed; \
  83. top: 0; \
  84. left: 0; \
  85. margin-left: 1ex; \
  86. background-color: rgba(255, 0, 0, 0.5) \
  87. width: 200px; \
  88. z-index: 6666; \
  89. opacity: 0.9; \
  90. height: 100%; \
  91. overflow-y: auto; \
  92. overflow-x: hidden;\
  93. resize:horizontal;\
  94. max-width:300px; \
  95. width:200px; \
  96. } \
  97. #gmRightSideBar p { \
  98. font-size: 80%; \
  99. } \
  100. #gmRightSideBar ul { \
  101. margin: 0ex; \
  102. } \
  103. } \
  104. " );
  105. jQuery(function() {
  106. var base_url = window.location.origin;
  107. jQuery.get(base_url+"/home"+"?forceads", "", function (data) {
  108. //jQuery(data).find("#boardmeta").appendTo ("#user_control_panel");
  109. //jQuery(data).find("#ucp_splash").appendTo ("#user_control_panel");
  110.  
  111. jQuery(data).find("#subscriptions").appendTo("#user_control_panel");
  112. jQuery(data).find(".ucp:has(thead tr th:contains(Forum Subscriptions))").appendTo ("#user_control_panel");
  113. jQuery("#subscriptions thead tr th").attr("colspan","2");
  114.  
  115. jQuery("#subscriptions .c_foot form").remove();
  116. jQuery(".ucp:has(thead tr th:contains(Forum Subscriptions)) .c_foot form").remove();
  117. }, "html");
  118.  
  119. });
  120. function addGlobalStyle(css) {
  121. var head, style;
  122. head = document.getElementsByTagName('head')[0];
  123. if (!head) { return; }
  124. style = document.createElement('style');
  125. style.type = 'text/css';
  126. style.innerHTML = css;
  127. head.appendChild(style);
  128. }
  129. addGlobalStyle('iframe {width:100% !important;}');
  130. addGlobalStyle('#subscriptions > thead:nth-child(1) > tr:nth-child(1) > th:nth-child(1) {display:none;}');
  131. addGlobalStyle('#cboxdiv {width:100% !important;}');
  132. 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;}');
  133. function loadjscssfile(filename, filetype){
  134. if (filetype=="js"){ //if filename is a external JavaScript file
  135. var fileref=document.createElement('script')
  136. fileref.setAttribute("type","text/javascript")
  137. fileref.setAttribute("src", filename)
  138. }
  139. else if (filetype=="css"){ //if filename is an external CSS file
  140. var fileref=document.createElement("link")
  141. fileref.setAttribute("rel", "stylesheet")
  142. fileref.setAttribute("type", "text/css")
  143. fileref.setAttribute("href", filename)
  144. }
  145. if (typeof fileref!="undefined")
  146. document.getElementsByTagName("head")[0].appendChild(fileref)
  147. }
  148. loadjscssfile("http://z3.ifrm.com/63/1/0/p481654/Quick_Search.js", "js") //dynamically load and add this .js file
  149. if (base_url != "http://starforcerp.com"){
  150. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5298252/zeta_cookie.js", "js") //dynamically load and add this .js file
  151. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5262218/confirm.js", "js") //dynamically load and add this .js file
  152. loadjscssfile("http://z5.ifrm.com/9054/18/0/f5310358/login_redirect.js", "js") //dynamically load and add this .js file
  153. }
  154. if (base_url != "http://sonic-cyclone.net"){
  155. // "Preview in Fast Reply" created by Holysavior of ZBCode and Javascriptin.com
  156. $("#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')"));
  157. $(".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>");
  158. $(".posting #c_post-text,#fast-reply dd textarea").keyup(function(){
  159. var characters = $(this).attr("value").length
  160. var words = $(this).attr("value").split(" ").length
  161. $("#posting_wordchars").html("<b>"+characters+" Characters -- "+words+" Words</b>");
  162. });
  163. }