KAT Headers Unified

Unifies and improves the headers of both the community and torrent sections of the site. (and makes community pages full width)

目前为 2018-08-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name KAT Headers Unified
  3. // @namespace NotNeo
  4. // @version 0.6
  5. // @description Unifies and improves the headers of both the community and torrent sections of the site. (and makes community pages full width)
  6. // @author NotNeo
  7. // @match https://katcr.co/*
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
  9. // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM.setValue
  13. // @grant GM.getValue
  14. // ==/UserScript==
  15.  
  16. var headerShrunkByDefault = "remember"; //yes,no,remember
  17. var url = window.location.href;
  18. var sessionId;
  19. var userName;
  20.  
  21. if(url.indexOf("/community") > -1) {
  22. //style
  23. if(true) {
  24. addGlobalStyle(`
  25. #wrapper {
  26. max-width: 100% !important;
  27. }
  28.  
  29. #header {
  30. padding-left: 5px;
  31. position: fixed;
  32. width: 100%;
  33. z-index: 100;
  34. }
  35.  
  36. #content_section {
  37. padding-top: 65px;
  38. }
  39.  
  40. #header div.frame {
  41. padding-right: 5px;
  42. }
  43.  
  44. #top_section > .forumtitle {
  45. margin-right: -55px;
  46. }
  47.  
  48. #top_section {
  49. min-height: 0px;
  50. }
  51.  
  52. #header > .frame > div:last-of-type, #header > .frame > br.clear {
  53. display: none;
  54. }
  55.  
  56. #menu_nav > li > ul {
  57. position: fixed;
  58. border: solid #333 2px;
  59. width: -moz-min-content;
  60. width: -webkit-min-content;
  61. }
  62.  
  63. #search_form {
  64. position: relative;
  65. }
  66.  
  67. #search_form .input_text {
  68. max-width: calc(100% - 1350px) !important;
  69. min-width: 200px;
  70. }
  71.  
  72. .valueBubble {
  73. display: inline-block;
  74. height: 7px;
  75. width: 7px;
  76. margin-bottom: 7px;
  77. margin-left: -10px;
  78. margin-right: -2px;
  79. font-family: sans-serif;
  80. color: #fc7208;
  81. background: #fc7208;
  82. border: 2px solid #594c2d;
  83. border-radius: 50%;
  84. transition: .1s all;
  85. }
  86.  
  87. .valueBubble span {
  88. position: absolute;
  89. margin-top: -22px;
  90. margin-left: 10px;
  91. font-size: 10px;
  92. }
  93.  
  94. #search-new-button {
  95. background: 0 0;
  96. color: #5f5f5f;
  97. box-shadow: none;
  98. display: inline-block;
  99. border: none;
  100. position: absolute;
  101. top: 0px;
  102. right: 12px;
  103. cursor: pointer;
  104. padding: 0 !important;
  105. }
  106.  
  107. #search-new-adv-button {
  108. background: 0 0;
  109. color: #5f5f5f !important;
  110. box-shadow: none;
  111. display: inline-block;
  112. border: none;
  113. position: absolute;
  114. top: 0px;
  115. right: 33px;
  116. cursor: pointer;
  117. padding: 0 !important;
  118. }
  119.  
  120. .columns-2 {
  121. -webkit-column-count: 2;
  122. -moz-column-count: 2;
  123. column-count: 2;
  124. -webkit-column-gap: 0;
  125. -moz-column-gap: 0;
  126. column-gap: 0;
  127. }
  128.  
  129. `);
  130. }
  131.  
  132. function addGlobalStyle(css) {
  133. var head, style;
  134. head = document.getElementsByTagName('head')[0];
  135. if (!head) { return; }
  136. style = document.createElement('style');
  137. style.type = 'text/css';
  138. style.innerHTML = css;
  139. head.appendChild(style);
  140. }
  141.  
  142. function CalcContentPad() {
  143. if($("#upshrink").attr("src").split("images/")[1] == "upshrink.png") {
  144. $("#content_section").prop("style", "padding-top: 165px;");
  145. }
  146. else {
  147. $("#content_section").prop("style", "padding-top: 65px;");
  148. }
  149. }
  150.  
  151. $("#siteslogan").detach().appendTo('#upper_section');
  152. $("#main_menu").parent().detach().appendTo("#top_section");
  153.  
  154. if(headerShrunkByDefault != "remember") { //if header shrink is "remember", let the site handle it...
  155. var imgSrc = $("#upshrink").attr("src").split("images/")[1]; //...else get current state
  156. if((headerShrunkByDefault == "yes" && imgSrc == "upshrink.png") || (headerShrunkByDefault == "no" && imgSrc == "upshrink2.png")) { //...and if the state is wrong...
  157. $("#upshrink").click(); //...change it
  158. }
  159. }
  160.  
  161. //remove search tab and add it to main search ba as advanced
  162. $("#button_search").remove();
  163. $("#search_form .button_submit").remove();
  164. $("#search_form .input_text").after('<a id="search-new-adv-button" title="Advanced Search" href="https://katcr.co/show/community/index.php?action=search"><i class="ka ka-settings"></i></a>');
  165. $("#search_form .input_text").after('<button name="submit" id="search-new-button" title="Search" type="submit"><i class="ka ka-search"></i></button>');
  166.  
  167.  
  168. //GetUserName
  169. userName = $(".greeting > span").text();
  170.  
  171. //Adding/removing/moving header parts
  172. $("#button_sitemap").remove();
  173. $("#button_help").remove();
  174. $("#gallery_torrents").remove();
  175. $("#menu_nav").prepend(`
  176. <li>
  177. <a class="firstlevel" onclick="return false;" href="#"><i class="ka ka-plus"></i> Other</a>
  178. <ul>
  179. <li class="topMsg">
  180. <a href="https://katcr.co/show/community/index.php?action=help">
  181. <i class="ka ka-idea"></i> Help</a>
  182. </li>
  183. <li class="topMsg">
  184. <a href="https://katcr.co/show/community/index.php?action=sitemap">
  185. <i class="ka ka-list"></i> Sitemap</a>
  186. </li>
  187. <li class="topMsg">
  188. <a href="https://katcr.co/gallery/movies/page/">
  189. <i class="ka ka-camera"></i> Gallery</a>
  190. </li>
  191. </ul>
  192. </li>
  193. `);
  194.  
  195. var numOfPM = $("#button_pm span.firstlevel strong").text() || 0;//get number of messages
  196. $("#button_pm").remove();
  197. $("#menu_nav").append(`
  198. <li id="button_pm">
  199. <a class="firstlevel" href="https://katcr.co/show/community/index.php?action=pm">
  200. <i class="ka ka-message"></i> <span class="valueBubble"><span>`+numOfPM+`</span></span> Messages
  201. </a>
  202. <ul class="navigation__sub_items">
  203. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=pm;sa=send" class="navigation__link"><i class="ka ka-edit"></i> New message</a></li>
  204. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=pm" class="navigation__link"><i class="ka ka-message"></i> Inbox</a></li>
  205. </ul>
  206. </li>
  207. `);
  208.  
  209. //Get session id for log out
  210. sessionId = $("#button_logout a").prop("href").split(";")[1];
  211.  
  212. $("#button_logout").remove();
  213. $("#button_profile").remove();
  214. $("#menu_nav").append(`
  215. <li id="button_profile">
  216. <a class="firstlevel" href="https://katcr.co/user/`+userName+`/profile/"><i class="ka ka-user"></i> `+userName+`</a>
  217. <ul class="navigation__sub_items" style="right: 45px;">
  218. <li class="navigation__item"><a href="https://katcr.co/user/`+userName+`/profile/" class="navigation__link"><i class="ka ka-torrent"></i> Torrent Profile</a></li>
  219. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=profile" class="navigation__link"><i class="ka ka-community"></i> Forum Profile</a></li>
  220. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=profile;area=forumprofile" class="navigation__link"><i class="ka ka-edit"></i> Edit Profile</a></li>
  221. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=logout;`+sessionId+`" class="navigation__link">Log out</a></li>
  222. </ul>
  223. </li>
  224. `);
  225.  
  226. $("#button_torrents ul").remove();
  227. $("#button_torrents .firstlevel").prop("href", "https://katcr.co/new/full/");
  228. $("#button_torrents").append(`
  229. <ul class="navigation__sub_items columns-2">
  230. <li class="navigation__item"><a class="navigation__link" href="/category/latest/page/"><i class="ka ka-torrent"></i> Latest</a></li>
  231. <li class="navigation__item"><a class="navigation__link" href="/category/movies/page/"><i class="ka ka-film"></i> Movies</a></li>
  232. <li class="navigation__item"><a class="navigation__link" href="/category/tv/page/"><i class="ka ka-film"></i> TV</a></li>
  233. <li class="navigation__item"><a class="navigation__link" href="/category/music/page/"><i class="ka ka-music-note"></i> Music</a></li>
  234. <li class="navigation__item"><a class="navigation__link" href="/category/games/page/"><i class="ka ka-tags"></i> Games</a></li>
  235. <li class="navigation__item"><a class="navigation__link" href="/category/books/page/"><i class="ka ka-bookmark"></i> Books</a></li>
  236. <li class="navigation__item"><a class="navigation__link" href="/new/full/"><i class="ka ka-torrent"></i> FULL</a></li>
  237. <li class="navigation__item"><a class="navigation__link" href="/category/applications/page/"><i class="ka ka-settings"></i> Apps</a></li>
  238. <li class="navigation__item"><a class="navigation__link" href="/category/anime/page/"><i class="ka ka-film"></i> Anime</a></li>
  239. <li class="navigation__item"><a class="navigation__link" href="/category/other/page/"><i class="ka ka-torrent"></i> Other</a></li>
  240. <li class="navigation__item"><a class="navigation__link" href="/category/xxx/page/"><i class="ka ka-delete"></i> XXX</a></li>
  241. <li class="navigation__item"><a class="navigation__link" href="/new/"><i class="ka ka-plus"></i> More</a></li>
  242. </ul>
  243. `);
  244.  
  245. /*$("#upload_torrents").append(`
  246. <ul class="navigation__sub_items">
  247. <li class="navigation__item"><a class="navigation__link" href="/remote/bot-upload/authval/info/"><i class="ka ka-idea"></i> REMOTE API</a></li>
  248. </ul>
  249. `);*/
  250.  
  251. CalcContentPad();
  252. $("#upshrink").click(CalcContentPad);
  253. }
  254. else {//====== Torrent Section =======
  255. userName = $(".navigation__item > .navigation__link .kf__user").parent().text();
  256. try {
  257. sessionId = $(".navigation__item .navigation__sub_items .navigation__link:contains('Log out')").prop("href").split(";")[1];
  258. } catch(err){ sessionId = false; };
  259.  
  260. $(".navigation__item > .navigation__link .kf__user").parent().parent().find("ul.navigation__sub_items").remove();
  261. $(".navigation__item > .navigation__link .kf__user").parent().after(`
  262. <ul class="navigation__sub_items">
  263. <li class="navigation__item"><a href="https://katcr.co/user/`+userName+`/profile/" class="navigation__link"><i class="kf__torrent button button--icon-button"></i> Torrent Profile</a></li>
  264. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=profile" class="navigation__link"><i class="kf__comments button button--icon-button"></i> Forum Profile</a></li>
  265. <li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=profile;area=forumprofile" class="navigation__link"><i class="kf__gear button button--icon-button"></i> Edit Profile</a></li>
  266. `+(sessionId ? '<li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=logout;'+sessionId+'" class="navigation__link">Log out</a></li>' : '')+`
  267. </ul>
  268. `);
  269.  
  270. $(".navigation__item > .navigation__link .kf__arrow_up").parent().parent().detach().prependTo("#js-scrollfix"); //Move upload to left
  271. $(".navigation__item > .navigation__link .kf__arrow_up").parent().parent().find("ul.navigation__sub_items").removeClass("columns-2").find("li:last").remove();
  272.  
  273. $(".navigation__item > .navigation__link .kf__camera").parent().parent().remove(); //remove gallery
  274. $("#js-scrollfix").prepend(`
  275. <li class="navigation__item">
  276. <a class="navigation__link" onclick="return false;" href="#"><i class="kf__plus"></i> Other</a>
  277. <ul class="navigation__sub_items">
  278. <li class="navigation__item">
  279. <a class="navigation__link" href="https://katcr.co/show/community/index.php?action=help">
  280. <i class="kf__question button button--icon-button"></i> Help</a>
  281. </li>
  282. <li class="navigation__item">
  283. <a class="navigation__link" href="https://katcr.co/show/community/index.php?action=sitemap">
  284. <i class="kf__list button button--icon-button"></i> Sitemap</a>
  285. </li>
  286. <li class="navigation__item">
  287. <a class="navigation__link" href="https://katcr.co/gallery/movies/page/">
  288. <i class="kf__camera button button--icon-button"></i> Gallery</a>
  289. </li>
  290. </ul>
  291. </li>
  292. `);
  293.  
  294. $(".navigation__item > .navigation__link[href='/new/'] .kf__torrent, .navigation__item > .navigation__link[href='https://katcr.co/new/'] .kf__torrent").parent().html('<i class="kf__torrent"></i> Browse Torrents');
  295. $(".navigation__item > .navigation__link[href='/new/'] .kf__torrent, .navigation__item > .navigation__link[href='https://katcr.co/new/'] .kf__torrent").parent().prop("href", "https://katcr.co/new/full/");
  296. }
  297.  
  298.  
  299.  
  300.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址