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-09-02 提交的版本,檢視 最新版本

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

QingJ © 2025

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