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 5
  11. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  12. // @grant GM_addStyle
  13. // ==/UserScript==
  14. $('.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>");
  15.  
  16. $("body").append ( ' \
  17. <div id="gmRightSideBar"> \
  18. <p>F9 toggles visibility</p> \ \
  19. <div id="user_control_panel" class="cat_head"> \
  20. </div> \
  21. </div> \
  22. ' );
  23. $('#cboxdiv').remove().clone().appendTo('#user_control_panel');
  24. //-- Fade panel when not in use
  25. var kbShortcutFired = false;
  26. var rightSideBar = $('#gmRightSideBar');
  27. rightSideBar.hover (
  28. function () {
  29. $(this).stop (true, false).fadeTo (50, 1 );
  30. kbShortcutFired = false;
  31. },
  32. function () {
  33. if ( ! kbShortcutFired ) {
  34. $(this).stop (true, false).fadeTo (900, 0.1);
  35. }
  36. kbShortcutFired = false;
  37. }
  38. );
  39. rightSideBar.fadeTo (2900, 0.1);
  40.  
  41. //-- Keyboard shortcut to show/hide our sidebar
  42. $(window).keydown (keyboardShortcutHandler);
  43.  
  44. function keyboardShortcutHandler (zEvent) {
  45. //--- On F9, Toggle our panel's visibility
  46. if (zEvent.which == 120) { // F9
  47. kbShortcutFired = true;
  48.  
  49. if (rightSideBar.is (":visible") ) {
  50. rightSideBar.stop (true, false).hide ();
  51. }
  52. else {
  53. //-- Reappear opaque to start
  54. rightSideBar.stop (true, false).show ();
  55. rightSideBar.fadeTo (0, 1);
  56. rightSideBar.fadeTo (2900, 0.1);
  57. }
  58.  
  59. zEvent.preventDefault ();
  60. zEvent.stopPropagation ();
  61. return false;
  62. }
  63. }
  64.  
  65. GM_addStyle ( " \
  66. #gmRightSideBar { \
  67. position: fixed; \
  68. top: 0; \
  69. left: 0; \
  70. margin: 1ex; \
  71. background-color: rgba(255, 0, 0, 0.5) \
  72. width: 200px; \
  73. max-width:200px; \
  74. z-index: 6666; \
  75. opacity: 0.9; \
  76. height: 100%; \
  77. overflow: auto; \
  78. } \
  79. #gmRightSideBar p { \
  80. font-size: 80%; \
  81. } \
  82. #gmRightSideBar ul { \
  83. margin: 0ex; \
  84. } \
  85. #gmRightSideBar a { \
  86. color: blue; \
  87. } \
  88. " );
  89. jQuery(function() {
  90. var base_url = window.location.origin;
  91. jQuery.get(base_url+"/home"+"?forceads", "", function (data) {
  92. //jQuery(data).find("#boardmeta").appendTo ("#user_control_panel");
  93. //jQuery(data).find("#ucp_splash").appendTo ("#user_control_panel");
  94.  
  95. jQuery(data).find("#subscriptions").appendTo("#user_control_panel");
  96. jQuery(data).find(".ucp:has(thead tr th:contains(Forum Subscriptions))").appendTo ("#user_control_panel");
  97. jQuery("#subscriptions thead tr th").attr("colspan","2");
  98.  
  99. jQuery("#subscriptions .c_foot form").remove();
  100. jQuery(".ucp:has(thead tr th:contains(Forum Subscriptions)) .c_foot form").remove();
  101. }, "html");
  102.  
  103. });
  104. function addGlobalStyle(css) {
  105. var head, style;
  106. head = document.getElementsByTagName('head')[0];
  107. if (!head) { return; }
  108. style = document.createElement('style');
  109. style.type = 'text/css';
  110. style.innerHTML = css;
  111. head.appendChild(style);
  112. }
  113. addGlobalStyle('iframe {width:100% !important;}');
  114. addGlobalStyle('#cboxdiv {width:100% !important;}');
  115. 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;}');