Greasy Fork is available in English.

Rutor Preview Ajax

Предпросмотр раздач на сайте

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. // ==UserScript==
  2. // @name Rutor Preview Ajax
  3. // @namespace https://github.com/AlekPet/
  4. // @version 1.4.6.9a
  5. // @description Предпросмотр раздач на сайте
  6. // @author AlekPet
  7. // @license MIT; https://opensource.org/licenses/MIT
  8. // @match http*://tor-ru.net/*
  9. // @match http*://zerkalo-rutor.org/*
  10. // @match http*://rutor.info/*
  11. // @match http*://rutor.is/*
  12. // @match http*://free-rutor.org/*
  13. // @match http*://freedom-tor.org/*
  14. // @match http*://top-tor.org/*
  15. // @match http*://rutor.is/*
  16. // @match http*://live-rutor.org/*
  17. // @match http*://xrutor.org/*
  18. // @match http*://rutor.info/*
  19. // @match http*://new-rutor.org/*
  20. // @match http*://6tor.org/*
  21. // @icon https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/icon.png
  22. // @connect *
  23. // @run-at document-end
  24. // @noframes
  25. // @grant GM_setValue
  26. // @grant GM_getValue
  27. // @grant GM_addStyle
  28. // @grant GM_addValueChangeListener
  29. // @grant GM.xmlHttpRequest
  30. // @grant GM_getResourceText
  31. // @require https://code.jquery.com/jquery-3.1.0.min.js
  32. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
  33. // ==/UserScript==
  34.  
  35. GM_addStyle(`
  36. .mDiv{width: 250px;border: 3px double #FFA302;/* right: 9px; */text-align: center; color: white;max-height: 90vh;overflow-y: auto;}
  37. .mDiv_title{background-image: url(/s/i/poisk_bg.gif);background-size: 40% 100%;padding: 5px;border-bottom: 2px solid #ffea00; cursor: pointer;}
  38. .mDiv_inner{width: 95%;overflow-y: auto;max-height: 300px;}
  39. .mDiv_FavInner{overflow-y: auto;max-height: 300px; color: silver; width: 80%;margin: 0 auto;padding: 10px;}
  40.  
  41. .mDiv_title.no_vis{filter: grayscale(1) brightness(1.5) !important;}
  42. .mDiv_title.opens{display:none;filter: hue-rotate(-40deg);}
  43. .mDiv_title.fav{filter: hue-rotate(200deg);}
  44. .mDiv_title.stream{filter: hue-rotate(120deg);}
  45.  
  46. .com_Style{background: linear-gradient(#b7b7b7,#545454);color: white;text-align: center;padding: 4px;cursor: pointer;user-select: none; width: 300px;margin: 0 auto;border-radius: 8px;transition: all 0.5s ease;margin-bottom: 10px;}
  47. .com_Style:hover {background: linear-gradient(#676666,#9e9e9e);width: 350px;transition: all 0.5s ease-out;font-size: 1.2em;}
  48.  
  49. #my_content{border: 1px solid silver;}
  50. .my_tr{display:none;}
  51.  
  52. .footSpoiler{text-align: center; padding: 10px;}
  53.  
  54. .box_comments{background: #d0caca;width: 90%;margin: 0 auto;padding: 10px;border-radius:8px;}
  55.  
  56. div#index tr.my_tr:hover { background-color: white;}
  57. div#my_content tr:hover { background-color: white;}
  58.  
  59. .buttonsStyle {border: 1px solid;width: 80%;margin: 3px auto;background: linear-gradient(#72ff72,#1d8e08);padding: 5px;cursor: pointer;}
  60. .buttonsStyle:hover{background: linear-gradient(#2fc12f,#246318);}
  61. .mDiv_FavControl{background: linear-gradient(#5a0067,#815f87);}
  62. .mDiv_FavControl:hover{background: linear-gradient(#be0a2f,#bc8ec5);}
  63. .mDiv_FavControlCheck{background: linear-gradient(#336700,#6e875f);}
  64. .mDiv_FavControlCheck:hover{background: linear-gradient(#07a116,#347036);}
  65. .butSpoiler{cursor:pointer; width: 16px;}
  66. .mDivFavControl_box{
  67. display: flex;
  68. margin: 0 20px;
  69. font-size: 0.8rem;
  70. }
  71.  
  72. div.seeEl {width: 80%;margin: 5px auto;background: linear-gradient(#e2a9d1,#ffc200);cursor: pointer;overflow: hidden;line-height: 1;font-size: 0.8em; box-sizing: content-box;color: black; font-weight: bold;font-family: monospace;}
  73. div.seeEl:hover{background: linear-gradient(#ff9b58,#f5ff0082); color: #8e0000;}
  74. div.seeEl div img:not(.butSpoiler) {box-shadow: 2px 2px 5px black;}
  75. .minipanel{display: table-cell;vertical-align: middle;padding: 5px;border-left: 1px dotted white;background: linear-gradient(#df99e8,#ff6400);}
  76. .minipanel:hover {background: linear-gradient(#d377de,#ff7000);}
  77. .minipanel:hover img{transition:1s all;transform: rotateX(360deg) !important;}
  78. .minipanel img{transition:1s all;}
  79.  
  80. .loading_tor_box{padding: 5px;}
  81. .loading_tor {width: 100%;background: #e0dcdc;border-radius: 8px;}
  82. .loading_tor_text{height: inherit;width: 0%;background: linear-gradient(#1dff60, #00b327);border-radius: 8px;color: #676767;font-size: 1em;padding: 2px;}
  83.  
  84. .checkbox_Load:not(checked) {opacity: 0;}
  85. .checkbox_Load + label {cursor: pointer;position: absolute;left: 35%;}
  86. .checkbox_Load:checked + label:before {background: #53d64c;}
  87. .checkbox_Load:checked + label:after {left: 5px;content: 'ON';color: green;}
  88. .checkbox_Load:not(checked) + label:before {content: '';position: absolute;top: 2px;left: -28px;width: 60px;height: 20px;background: #ff6060;box-shadow: inset 0 2px 3px rgba(0,0,0,.2);}
  89. .checkbox_Load:not(checked) + label:after {content: 'OFF';position: absolute;top: 4px;left: -25px;width: 25px;height: 15px;background: #FFF;box-shadow: 0 2px 5px rgba(0,0,0,.3);transition: all .2s;}
  90. div.imgages_Load {display: table; border-collapse: collapse; color: #b40000;font-family: monospace;font-weight: bold;}
  91. .preLoadImagesCell{display: table-cell;height: 40px;vertical-align: middle;background: #fbf7f7;text-align: center;width: 40%;}
  92. .preLoadImagesRow{display:table-row;}
  93. .preLoadImagesRow #timoutTimeImages {width:50%;text-align: right;color: #00447f;font-family: monospace;font-weight: bold;}
  94. .splitter{border-top: 1px solid silver;}
  95.  
  96. tr.gai td a[href='javascript:void(0);'], tr.tum td a[href='javascript:void(0);']{margin-right: 5px;}
  97. tr.gai td a[href='javascript:void(0);'] img, tr.tum td a[href='javascript:void(0);'] img, .box_buttons_inner a[href='javascript:void(0);'] img{transition:1s transform;}
  98. tr.gai td a[href='javascript:void(0);'] img:hover, tr.tum td a[href='javascript:void(0);'] img:hover, .box_buttons_inner a[href='javascript:void(0);'] img:hover{transform: scale(1.3);filter: hue-rotate(270deg);}
  99. .FavBlockEl{margin: 0 5px 10px 0;background: #fbf7f7;box-shadow: 2px 2px 5px silver;}
  100. .FavBlockEl a {text-decoration: none;font-size: 0.8em;font-weight: bold;}
  101. .FavBlockEl a:hover {color: #73046a !important;}
  102. .FavBlockEl > div:nth-child(2) div {margin: 5px 0 5px 0;}
  103. .FavBlockEl > div:nth-child(3) {display: table-cell;vertical-align: middle;padding: 5px;border-left: 1px dotted;background: linear-gradient(to bottom, #fbf7f7, #ffc7c7);font-weight: bold;color: orange;user-select: none;cursor: pointer;}
  104. .FavBlockEl > div:nth-child(3):hover{background: linear-gradient(#ffd4d4 50%, #f59999);}
  105. .poleLinks{display:block;transition: 1s transform;}
  106. .poleLinks:hover{transform: scale(1.4);}
  107. .mDiv_Popup {background: #fbf7f7;width: 300px;border: 1px solid silver;box-shadow: 4px 4px 8px #00000073;border-radius: 6px;margin: 10% auto;text-align: center; display:none;}
  108. .mDiv_Popup > .mDiv_Popup_title {padding: 5px;font-size: 1.2em;font-family: cursive;border-radius: 6px 6px 0 0;background-image: url(/s/i/poisk_bg.gif);background-size: 40% 100%;color:white;}
  109. .mDiv_Popup > .mDiv_Popup_message_box {font-size: 1em;text-align: center;line-height: 1.5;color: darkslategrey;border-radius: 0 0 6px 6px;border-top: 1px solid #1d1d1d;}
  110. .mDiv_Popup_message_box > .mDiv_Popup_message {padding: 10px;max-height: 500px;min-height: 90px;overflow-y: auto;}
  111. .mDiv_Popup_smoke {position: fixed;background: #000000a6;left: 0;top: 0;width: 100%;height: 100%;display: none;z-index:3;}
  112. .box_buttons_inner {display: inline-block;margin-left: 20px;}
  113. .mDiv_Popup_title_x {float: right; cursor: pointer;}
  114. .mDiv_Popup_title_x:after {content: 'X';}
  115. .mDiv_Popup_title_x:hover {color: yellow;}
  116. tr.backgr td > div {display: inline;}
  117. .blend_class{background-blend-mode: luminosity;background-color: #ffd74540;}
  118. /*---*/
  119. .pop_panel{
  120. margin-right: 5px;
  121. position: relative;
  122. }
  123. .pop_elements {
  124. position: absolute;
  125. background: white;
  126. padding: 6px;
  127. text-align: center;
  128. border: 1px solid silver;
  129. top: -20px;
  130. right: 50%;
  131. width: max-content;
  132. height: -webkit-fill-available;
  133. border-radius: 6px;
  134. box-shadow: 0px 2px 4px 0px silver;
  135. display: none;
  136. }
  137. .pop_panel:hover > .pop_elements{
  138. display: block;
  139. }
  140.  
  141. .pop_elements a {
  142. position: relative;
  143. margin: 0px 10px;
  144. }
  145. .pop_elements a span {
  146. position: absolute;
  147. font-size: 5px;
  148. top: 13px;
  149. left: 50%;
  150. transform: translate(-50%, 0px);
  151. color: silver;
  152. }
  153. /*.pop_elements a[data-servname]:after {
  154. content: attr(data-servname);
  155. font-size: 8px;
  156. text-decoration: none;
  157. }*/
  158.  
  159. .service_splitter{
  160. border-right: 2px dotted silver;
  161. padding-right: 5px;
  162. }
  163.  
  164. #torrentPlayer {
  165. position: fixed;
  166. top: 50%;
  167. left: 50%;
  168. transform: translate(-50%, -50%);
  169. border: 1px solid silver;
  170. user-select: none;
  171. font-family: monospace;
  172. background: #ffffffcf;
  173. color: white;
  174. display: flex;
  175. flex-direction: column;
  176. justify-content: center;
  177. align-content: center;
  178. max-width: 35vw;
  179. }
  180.  
  181. .torrentPlayer_video {
  182. position: relative;
  183. height: 0;
  184. padding-bottom: 56.25%;
  185. background: #000000d1;
  186. }
  187.  
  188. .torrentPlayer_video iframe{
  189. position: absolute;
  190. width: 100%;
  191. height: 100%;
  192. top: 0;
  193. left: 0;
  194. }
  195.  
  196. .torrentPlayer_list {
  197. color: #810c0c;
  198. padding: 2px;
  199. line-height: 2;
  200. font-weight: bold;
  201. }
  202.  
  203. .torrentPlayer_title {
  204. background: black;
  205. font-weight: bold;
  206. text-align: center;
  207. }
  208.  
  209. .torrentPlayer_info {}
  210.  
  211. .torrentPlayer_close {
  212. cursor: pointer;
  213. position: absolute;
  214. right: -12px;
  215. top: -15px;
  216. background: #c0c0c0e0;
  217. border-radius: 100%;
  218. padding: 10px;
  219. z-index: 1;
  220. }
  221. .torrentPlayer_close:hover {
  222. background: #939393de;
  223. }
  224.  
  225. .torrentPlayer_playlist {
  226. max-height: 200px;
  227. overflow-y: scroll;
  228. list-style: none;
  229. display: flex;
  230. flex-direction: column;
  231. margin: 2px;
  232. padding: 4px;
  233. }
  234.  
  235. .torrentPlayer_playlist li {
  236. cursor: pointer;
  237. border: 1px solid #ffa302;
  238. background: linear-gradient(45deg, #fed304, transparent);
  239. border-radius: 4px;
  240. padding: 0 6px;
  241. margin: 2px;
  242. display: flex;
  243. flex-direction: row;
  244. align-items: center;
  245. justify-content: space-between;
  246. word-break: break-all;
  247. }
  248.  
  249. .torrentPlayer_playlist_item_title{
  250. text-align: left;
  251. border-right: 2px dotted orange;
  252. width: 90%;
  253. }
  254.  
  255. .torrentPlayer_playlist_item_title_item_size {
  256. padding: 0 3px;
  257. width: 10%;
  258. text-align: center;
  259. }
  260. .activExists:first-child:before {
  261. content: attr(data-exists);
  262. background: green;
  263. position: absolute;
  264. top: 50%;
  265. transform: translateY(-50%);
  266. left: -10px;
  267. writing-mode: vertical-lr;
  268. text-orientation: upright;
  269. color: wheat;
  270. padding: 2px;
  271. font-size: 0.7rem;
  272. }
  273. .activExistsRed:first-child:before{
  274. background: red;
  275. }
  276. .mDiv::-webkit-scrollbar {
  277. width: 7px;
  278. }
  279. .mDiv::-webkit-scrollbar-track {
  280. box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  281. }
  282. .mDiv::-webkit-scrollbar-track{
  283. background: #caffd1;
  284. }
  285. .mDiv::-webkit-scrollbar-thumb {
  286. background: darkseagreen;
  287. box-shadow: inset 0 0 0px 2px rgb(38 175 13 / 44%);
  288. }
  289. `);
  290.  
  291. /* sorted plugin jquery
  292.  
  293. tr.backgr td:not(:first-child):not(:last-child) {background: url(/agrrr/img/sort-bg.gif) 100% -70px no-repeat;font-size: 12px;text-align: left;cursor: pointer;padding-right: 19px;}
  294. tr.backgr td.headerSortUp{background-position-y: -20px;}
  295. tr.backgr td.headerSortDown{background-position-y: -120px;}
  296.  
  297. tr.backgr td > div.headerSortUp{background-position-y: -135px;}
  298. tr.backgr td > div.headerSortDown{background-position-y: -36px;}
  299. tr.backgr td > div {background: url(/agrrr/img/sort-bg.gif) 100% -86px no-repeat;font-size: 12px;text-align: left;cursor: pointer;padding-right: 20px;display: inline;height: 20px;position: relative;top: 1px;}
  300. */
  301.  
  302. (function() {
  303. 'use strict';
  304. const $ = window.jQuery,
  305. image_arrow = "https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/arrow_icon.gif",
  306. no_image = "https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/no_image.png",
  307. favIcon = "https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/yellow_heart.png",//"https://aminoapps.com/static/bower/emojify.js/images/emoji/yellow_heart.png",
  308. searchIcon = "https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/search_icon.png",
  309. torrServIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACplBMVEVVVVVURkdYT1B1WD9KPT1SR0hORUYtISIsJCYrISIzIiIsIyVcOhotICJ8eXdeVlZWTE1QRkdLQUNQRkeZajbTeBlbU1RSSElGPT1DOjppTC93Uy5RSEhaU1VUTExLQkJANjdMQkJPQk5IPD4/NjU/NTVPQ05DOTs9MjM9MDE/NjVAODY3Ky03Kyw2Kis1KSo0KCkxJihDOzlDOjkxJyguJCQ3LC0fDg0wJSZANjY/NTYnHR4yJihANzlBODgiGR89LCNwSB9ZSDtLQ0I5Li8vJCUqHR7gfQBXNxstIiY2Kyw2LC0vIyUsICAfCQ1NRkRYVU9ZWlBMRkVWUEyAgXeXlo2fpJaeqJiolHC8hjliV0hjYVmRkIebnJKem5Shp5y3rIjhmTS7oXGXn5FjX1lZXE+apJGNi4RuaWVoYmKTh23kmS7WnEmrrZ+orJ6Zno9YWE6EjXuosp+rrqKMjoaFdmXmoDf3kw7TolnIp22uspyor5+EjntOSESapZGqsqGusqagm4a/fCf8kwf+kgHwlRnEq3qttaaprqCYn49OSURaVFChq5ers6KvsaeimoOqgEv0lhj4jwbJomGwuaqvuKipraCgppZaWVBaVVCrsqKusKanq5/Hj0L+lATGfiOGdmB8e3Kgp5irsKKgqJZbXFJQSkabp5KrtaKsrqXIrnf5lg3/kgDhhQ21jFCQj4SXnI6rsaFSTkeJlYCotKCtrJvNoFrnkyT4jgTJjD6EfHB1c22SlYmnrJ6Fh3xjZVqcqpOnq56xrZPimDPQlEKAdm2YmZGEgnt2dmybn5FhXFhxcmman5HKoFvUmkaurpmQj4l4c255d2+MlYNxcWiBa028ikGgnYagqpmgopaZmo+KjIBoaGBeW1dramNqZmFfWVb///9Brb7hAAAAT3RSTlMAAAAAAAAAAAAAAAAAAAI0h8PewkMID3bc/f3heA8Pk/mTAnb5+QI03If9/cPD3t7Dh/39hzTcAnb5+Q+T+fkPe+L8/dx2Dww9ht7ehzQC034NnwAAAAFiS0dE4V8Iz6YAAAAHdElNRQfnARcNDQ5t9QcVAAABG0lEQVQY0wEQAe/+AAABAg4PEBESEhMQFBUDAQAABAUWFxgZT1BRUhobHB0FBAAGHh8gU1RVVldYWVogIR4GACIjJFtcXV5fYGFiY2QlIyYAJyhlZmdoaWprbG1ub3AoJwApKnFyc3R1dnd4eXp7fCspACx9fn+AgYKDhIWGh4iJii0ALouMjY6PkJGSk5SVlpeYLgAvmYyam5ydnp+goaKjpKUvADCmp6ipqqusra6vsLFvsjAAMTKztLW2t7i5uru8vb4zNAA1Nr/AwcLDxMXGx8jJyjY1ADc4OcvMzc7P0NHS09Q6ODcABzs8PdXW19jZ2tvcPjw7BwAICT9AQULd3t/gQ0RFRgkIAAoLDEdISTBKSzBMTU4NCwoBwWbifpX7rQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMy0wMS0yM1QxMzoxMjo1MyswMDowMINE+WMAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjMtMDEtMjNUMTM6MTI6NTMrMDA6MDDyGUHfAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDIzLTAxLTIzVDEzOjEzOjE0KzAwOjAwCyM7SgAAAABJRU5ErkJggg==",
  310. torrServToAdd = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABDlBMVEVKr1BKrzBLr09Lrk9Mo0ZLrlF0w19Mrk5Lrk5PqkZMr1BLrlBMr05Mrk9avjNKrk5Lr1BCtGJHpUFLr045vlVNrE1Lrk9Krk9Lrk9Lrk9Lrk9Lrk9Mrk9Mr05Mr09Lrk9Lrk9Lrk9Lrk9Lrk9Mrk9Lrk9Lrk9Lrk9Lr09JrU5Lrk9Lr09Lrk9Lrk9Lrk9Lrk9Lrk9Lrk9Mrk9Lrk9LrlBLsE5Lrk9Mrk9Kr05Lrk9MrlBLrk5Mr09Lrk9IrU1Krk9TsVaJyoxTslZKrU5gt2Pq9utguGRIrUxft2Lt9+7u9+5guGNSsVZet2JdtmFxv3Tv+O/v+PBywHWKyo3q9urt9+39/v1xv3Vft2P///+b6o0DAAAAPXRSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkei3fncSgcajujrjRcarf6pFwaMB+nqSaH420lIBweoFxaLB0gHlFkjPAAAAAFiS0dEWZqy9BgAAAAJcEhZcwAAAOwAAADsAXkocb0AAAAHdElNRQfnARcNDQ5t9QcVAAAA0UlEQVQY02NgYGQSE5eQlJKSlpCRZWZhZWBjl5NXsAUDRSVlDk4GLhVVEMfODkioqWtwM2jKA1n2Do6OTvZAES1tBnEdoICzi6urmzOQoavHIAHiu3t4enm7g0T0GSRtbX18/fwDAoP8fH1sbaUZpGztgkNCA8LCAkJdg91tDTAFIFrCAwPDwVoMoYZGeHpGQA01UoRa6wK21pjBREsN6DAfR0cfsMNMGXiU1dXgTjcz52Xg47ew1IV4TlfLXECQgVWI2UpPX9rAwFDf2kZYRBQA9Mo2aHeqks0AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjMtMDEtMjNUMTM6MTI6MjgrMDA6MDCLhqSAAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIzLTAxLTIzVDEzOjEyOjI4KzAwOjAw+tscPAAAACh0RVh0ZGF0ZTp0aW1lc3RhbXAAMjAyMy0wMS0yM1QxMzoxMzoxNCswMDowMAsjO0oAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC",
  311. aceStreamIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACZFBMVEX//wD/+CL/////dFgAAAD/yf//6AP//wP/fVn/5a3//xFds8v//zOm//9izl8y03NXpbxmxeAA7/9CsZQA/xA+7JGD+v88/44w0XJft9Bu1PEAAAABAQDuVUH4WUT5WUTyVj0KAAAAAAEKBQD4fQD6egfxWzj9W0X+W0X+W0X/W0H6WkncVFsBAQEEAgDhcQD9fwD9gAD+Xz3+W0X+W0X+W0PRVXWdVM+eVNGdUsoSCQD9gAD+gAD6YzP+W0b/W0X/W0ONUNmcVNSdVdSdVdSdVdScVNOYUs36fgD+gAD+gAD7YzP9WkX5WUS6PA2OTMCcVNOdVdScVNOcVNOdVdScVNP4gQL+gAD+gAD9gACKRridUtLoAMCAOaecVNOdVdP1wiP3tBz+fwD+gADjcgADAgA6fohGjJ1Hi50BfU2fS9GcVNP8xiT1wyTYeQbxhwcCBARIip1JjJ9IjJ5WgKX8xiX8xiT7xiT6xiQHBgFBfJBIi55JjJ9Ii55Ih5yUGKf8xiT9xyX9xyX8xiXyvCEhk08hoE9DjJRIi55Ji55JjJ/6xCT9xyT9xyX8xiTTuisipVsnplonp1smplonmlxEfJVJi55JjJ9HiZzqviX/xiP/xiAABjAmplomplpHiZxJjJ9Ji55DgpQ0plUjpVoaolwlpVonp1snp1snp1smpVlIi55Ji59Iip0BAgMdj08mplonp1onp1onp1omplompFkmplkwmG5Ii55Ii55Ii50KLxglolgmpVklolgSVS1GdpxIip5Ii55HiJsBAgIBAwE/e45FhpgAAQFJjJ8np1v///+JAouZAAAAyXRSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQggIAsBAQEWGw5SmpFnPQsBAQZTTmy/skEUQYEjAWyDHsDXXRWe8fnNghkq1nIiQRcDCHrde6f0oRit9WIGNAEEctobGXKHBwEHaUQDFZZxHQYJAUDwnC/QZGJAAQmq/JUmAsHy9LQMBhMldcv5MM3njRQ/gLKbDAi88TITXCoBi3wq6LoNGUYwQuPo5DSO5kMBBV/E4tqPMlITZsJNAR0wGwIHRGMfAQEFCwGmiBL/AAAAAWJLR0QCZgt8ZAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB+cBFw0NDfT8Vq8AAAEbSURBVBjTARAB7/4AGxsbHBsAAQIDHR4fICEiGwAbGyMEACQlJicoKSorLAQtABsuBC8wMTIzNDU2Nzg5BQIAGxs6Ozw9Pj9AQUJDREVGRwAbBkhJSktMTU5PUFFSU1RVAAdWV1hZBAgJGwRaW1xdXl8AYGFiY2QEZRsbBGZnaGlqawBsbW5vCiMbG3ALcXJyc3RbAHV2d3gMeRsEDXp7yXx9fn8AgIGCg4QOD4WGh4iJinEQGwCLjI2Oj5CRkpOUlZaXmBEbAJmamxKcncrKnhOfoKGiBBsAo6Slpp2nqKmqFKusrRGuGwCvsLGys7S1tre4uboEGxsbAAS7vL2+vxXAwcLDFhvEGxsAxRsXGBcEG8bHGRobyBsbG5hpVpaCHPp+AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIzLTAxLTIzVDEzOjEyOjI4KzAwOjAwi4akgAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMy0wMS0yM1QxMzoxMjoyOCswMDowMPrbHDwAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjMtMDEtMjNUMTM6MTM6MTMrMDA6MDDOhAXEAAAAAElFTkSuQmCC",
  312.  
  313.  
  314. images_ = [image_arrow,no_image,favIcon,searchIcon,torrServIcon],
  315.  
  316. hostname = location.origin,
  317.  
  318. debug = 0,
  319. torr_serv_port = 8090,
  320. acestream_port = 6878
  321.  
  322. var ObjSave = null,
  323. TimeOutImages = 5;
  324.  
  325. GM_addValueChangeListener('ObjSave', function() {
  326. let ls_value = GM_getValue('ObjSave');
  327.  
  328. ObjSave = (ls_value)?JSON.parse(ls_value):{};
  329. updateFav();
  330. updateForm();
  331. });
  332.  
  333. function checkLocaltorage(){
  334. if(ObjSave){
  335. if (!ObjSave.hasOwnProperty('favorites')){
  336. ObjSave.favorites = [];
  337. }
  338.  
  339. if (!ObjSave.hasOwnProperty('options')){
  340. ObjSave.options = {};
  341. }
  342.  
  343. if(debug) console.log("Объект: ",ObjSave);
  344. }
  345. }
  346.  
  347. function loadStorage(){
  348. let ObjSave_tmp = GM_getValue('ObjSave');
  349.  
  350. ObjSave = (ObjSave_tmp) ? JSON.parse(GM_getValue('ObjSave')) : {
  351. options: {}
  352. };
  353.  
  354. checkLocaltorage();
  355. }
  356.  
  357. function saveToStorage(){
  358. try{
  359. var save_data = JSON.stringify(ObjSave);
  360.  
  361. if(save_data.length>0 && save_data !== null && save_data !=="" && save_data !== undefined){
  362. GM_setValue('ObjSave', save_data);
  363. if(debug) console.log("Сохраненно: ",ObjSave);
  364. }
  365. }catch(e){
  366. console.log(e);
  367. }
  368. }
  369.  
  370. function LoadingImages(param){
  371. try{
  372. //Images
  373. let callback = param.func,
  374. content = param.content,
  375. button = param.button,
  376. elem = param.elem,
  377. IMGElements = $(content).find('#details tr:eq(0) img:not([src^="http://rublacklist.net"])'),
  378. lenIMG = IMGElements.length,
  379.  
  380.  
  381. progressBar = $(elem).nextAll(":eq(0)"),
  382. progressBarText = progressBar.find(".loading_tor_text"),
  383. procentuno = 100/lenIMG;
  384.  
  385. if(lenIMG > 0){
  386. if(debug){
  387. console.log(`Изображений найдено: ${lenIMG}\n------------------------------`);
  388. console.log("Тайм-аут равен: ", TimeOutImages, "Если 0 тайм-аут выкл.");
  389. }
  390.  
  391. let imgLoaded = 0,
  392. procentLoaded = 0;
  393.  
  394. progressBar.show();
  395.  
  396. $(IMGElements).each(function(){
  397. let image = this,
  398. timer = null;
  399.  
  400. $(image).one("load", function(){
  401. if (timer) {
  402. clearTimeout(timer);
  403. timer = null;
  404. }
  405.  
  406. imgLoaded++;
  407.  
  408. if(debug) console.log("Изображений загруженно: ",imgLoaded);
  409.  
  410. procentLoaded += procentuno;
  411. progressBarText.css("width", procentLoaded+"%");
  412. progressBarText.text("Загружено "+procentLoaded.toFixed(1)+"%");
  413.  
  414. if(imgLoaded === lenIMG){
  415. progressBarText.text("100.0%");
  416. progressBarText.css("width", "100%");
  417. callback(param);
  418. progressBar.fadeOut('slow');
  419. }
  420. })
  421. .one('error', function() {
  422. let src = $(this).attr("src");
  423.  
  424. $(this).attr({
  425. "title": "Изображение не найдено:\n"+src,
  426. "src": no_image,
  427. "error_image": 1
  428. }).css({"cursor":"pointer"});
  429. $(this).click(function(){window.open(src);});
  430. })
  431. .attr("src",image.src);
  432.  
  433. if(TimeOutImages !== 0){
  434. timer = setTimeout(function(theImg) {
  435. return function() {
  436. if(debug) console.log(`Таймер истек: ${theImg.src}\n------------------------------`);
  437.  
  438. theImg.onload = theImg.onabort = theImg.onerror = function() {};
  439.  
  440. if (timer) {
  441. clearTimeout(timer);
  442. timer = null;
  443. }
  444.  
  445. let src = $(theImg).attr("src");
  446.  
  447. $(theImg).attr({
  448. "title": "Изображение не найдено:\n"+src,
  449. "src": no_image,
  450. "error_image": 1
  451. }).css({"cursor":"pointer"}).click(function(){window.open(src);});
  452.  
  453. if(imgLoaded === lenIMG){
  454. progressBarText.text("100.0%");
  455. progressBarText.css("width", "100%");
  456. callback(param);
  457. progressBar.fadeOut('slow');
  458. }
  459. };
  460. }(image), TimeOutImages*1000);
  461. }
  462. });
  463. }
  464. } catch(e){
  465. console.log(e);
  466. }
  467. }
  468.  
  469. // Правим полученный контент
  470. function modifyData(param){
  471. var data = param.data,
  472. button = param.button,
  473. elem = param.elem,
  474.  
  475. content = $(data).find("#content")[0] || undefined;
  476.  
  477. if (!content){
  478. let nextEl = $(elem).next().next().children(0);
  479.  
  480. $(nextEl).html("<div style='text-align: center;font: italic 12pt monospace;color:red;'>Страница пока не доступна!</div>");
  481. return false;
  482. }
  483.  
  484. content.removeChild(content.children[0]);
  485. content.removeChild(content.children[0]);
  486. content.removeChild(content.lastElementChild);
  487. content.removeChild(content.lastElementChild);
  488.  
  489. $(content).find("tr").not(".c_h").hover(function(){$(this).css("background-color","transparent");},function(){$(this).css("background-color","transparent");});
  490.  
  491. let tableCount = $(content).find("table tr[class^='c_h']").length;
  492.  
  493. // Список файлов измененная загрузка
  494. let descrN = $(content).find(".header span").attr("onclick").toString().match(/descriptions\/(\d+)\.files/i)[1];
  495. $(content).find(".header span").removeAttr("onclick");
  496. $(content).find(".header span").attr("filelist_already_loaded", 0);
  497.  
  498. $(content).find(".header span").click(function(){
  499. if($(this).attr("filelist_already_loaded") == 0){
  500. $(this).attr("filelist_already_loaded",1);
  501. $(content).find('#filelist').load('/descriptions/'+descrN+'.files');
  502. }
  503. $(content).find('#displayfiles').fadeToggle('slow', 'linear');
  504. });
  505. //
  506.  
  507. $(content).find("#cem").before('<div class="box_comments"><div title="Показать комментарии" class="com_Style">Комментарии'+(tableCount>0?' ('+tableCount+')':'')+'</div><div style="display:none;" id="hiden_cc"></div></div>');
  508.  
  509. $(content).find(".com_Style").click(function(){$(this).next().fadeToggle( 'slow', 'linear');});
  510.  
  511. $(content).find("#hiden_cc").append($(content).find("#cem"));
  512.  
  513. let tableCom = $(content).find("table tr[class^='c_h']").parent().parent();
  514.  
  515. $(content).find("#hiden_cc").append(tableCom.prev(),tableCom.prev().prev(),tableCom);
  516.  
  517. let cloneButton = (button.clone(true)).attr("title","Скрыть раздачу"),
  518.  
  519. spoiler = $("<div class='footSpoiler'></div>").html(cloneButton);
  520.  
  521. $(content).append(spoiler);
  522.  
  523. content.id = "my_content";
  524.  
  525.  
  526. let nextEl = $(elem).next().next().children(0);
  527.  
  528. $(nextEl).html(content);
  529.  
  530. if(debug) console.log("Предзагрузка включена...",$(".checkbox_Load")[0].checked);
  531.  
  532. if($(".checkbox_Load")[0].checked){
  533. LoadingImages({content:content, button:button, elem:elem, func: ShowIHide});
  534. } else {
  535. ShowIHide({button:button, elem:elem});
  536. }
  537. }
  538.  
  539. function MiniPanel(param){
  540. let button = param.button,
  541. elem = param.elem;
  542.  
  543. // Add see
  544. $(".mDiv_title.opens").show();
  545. let a_elems = $(elem).children()[2].children[4].href.indexOf('magnet') == -1 ? $(elem).children()[2].children[4]: $(elem).children()[2].children[5],
  546. textPop = a_elems.innerText,//.children(1).children()[5].innerText,
  547.  
  548. imgSmall = $(elem).nextAll(".my_tr:eq(0)").find('table#details tr:eq(0) img:not([error_image])').filter(function(i,val){
  549. if(val.width > 150 && !/banner|kinopoisk|imdb/i.test(this.src)){
  550. return this;
  551. }
  552. });
  553.  
  554. if(imgSmall.length>0){
  555. let elOut = imgSmall[0];
  556. for(let i of imgSmall){
  557. if(i.height > elOut.height) {
  558. elOut = i;
  559. }
  560. }
  561. imgSmall = elOut.src;
  562. } else {
  563. imgSmall = no_image ;
  564. }
  565.  
  566. if(debug) console.log("Мини изображение: ",imgSmall);
  567.  
  568. let imgEl = $('<img>').attr({
  569. src: imgSmall,
  570. width: "50px"
  571. }),
  572.  
  573. imgBox = $('<div style="display: table-cell;vertical-align: middle;padding:5px;border-right: 1px dotted white;"></div>').append(imgEl),
  574. textBox = $('<div style="display: table-cell;vertical-align: middle;font-size: unset;padding:2px;word-break: break-all;"></div>').text(textPop),
  575. hide = button.clone(true),
  576. hideE = $._data(hide[0], "events"),
  577. addonBox = $('<div class="minipanel"></div>').attr('title',hide.attr('title')).each(function () {
  578. for (var type in hideE){
  579. for (var handler in hideE[type]){
  580. if(handler === 'delegateCount') continue;
  581. $.event.add(this, type, hideE[type][handler], hideE[type].data);
  582. }
  583. }
  584. }).append(hide.off()),
  585.  
  586. elSee = $('<div class="seeEl"></div>').attr('title',textPop).append(imgBox, textBox,addonBox);
  587.  
  588. $(imgBox).add(textBox).click(function(){
  589. let offset = $(elem).offset().top;
  590. $('html, body').animate({scrollTop:offset}, 500, 'swing');
  591. });
  592.  
  593. $(elem).data(elSee);
  594.  
  595. $(".mDiv_inner").append(elSee).animate({scrollTop:$("div.mDiv_inner").offset().top}, 500, 'swing');
  596. }
  597.  
  598. // Функция появления и прочее
  599. function ShowIHide(param){
  600. let elem = param.elem,
  601. button = param.button,
  602. event_el = param.event_el || null;
  603.  
  604. $(elem).nextAll(".my_tr:eq(0)").animate(
  605. {
  606. width: [ "toggle", "swing" ],
  607. height: [ "toggle", "swing" ],
  608. opacity: "toggle"
  609. }, 1500, "linear", function(){
  610. if($(this).css("display") === "none"){
  611. button.css("transform", "scaleY(1)").attr("title","Показать раздачу");
  612.  
  613. // Remove see
  614. $(".mDiv_inner")[0].removeChild($(elem).data()[0]);
  615. if($(".my_tr:visible").length<1){
  616. $(".mDiv_title.opens").hide();
  617. }
  618.  
  619. } else {
  620. button.css("transform", "scaleY(-1)").attr("title","Скрыть раздачу");
  621.  
  622. // Mini Panel
  623. MiniPanel(param);
  624. }
  625.  
  626. const lenSee = $(".seeEl").length
  627. if(lenSee>0){
  628. $("#hideAll").fadeIn('fast')
  629. } else {
  630. $("#hideAll").fadeOut('fast')
  631. }
  632.  
  633. $(".mDiv_title.opens").text(`Открытые (${lenSee})`);
  634.  
  635. // Back offset on page
  636. //if(event_el !== "minipanel") $('html, body').animate({scrollTop:$(elem).offset().top}, 500, 'swing');
  637. $('html, body').animate({scrollTop:$(elem).offset().top}, 500, 'swing');
  638. });
  639. }
  640.  
  641. // Ajax запрос
  642. function ajaxJQ(param){
  643. if(debug) console.log("Ajax proceed...");
  644.  
  645. let button = param.button,
  646. link = param.link,
  647. elem = param.elem;
  648.  
  649. return new Promise(function(resolve, reject){
  650. $.ajax({
  651. url: link,
  652. success: function(data){
  653. if(debug) console.log("Ajax запрос завершен!");
  654.  
  655. //let ObjData = {data:data,button:button,elem:elem};
  656. //modifyData(ObjData);
  657. resolve({data:data,button:button,elem:elem})
  658. },
  659. error: function(e)
  660. {
  661. let nextEl = $(elem).next().next().children(0);
  662. $(nextEl).css({"text-align":"center","color":"red"}).text(e.statusText.toUpperCase()+": Нет ответа от сервера")
  663. ShowIHide({button:button, elem:elem});
  664. reject(null)
  665. }
  666. });
  667. })
  668.  
  669. }
  670.  
  671. function MakeFav(param){
  672. let elem = param.el || null,
  673. link = param.link,
  674. linkText = param.linkText,
  675. id = param.id,
  676. Down = param.Down,
  677. Mdown = param.Mdown,
  678. date_time = param.date_time,
  679. category = param.category,
  680. index = param.index,
  681. isExists = param.object?.isExists == undefined ? '' : param.object?.isExists?'OK':'NO',
  682.  
  683. searchText = searchEditReq(linkText),
  684.  
  685. FavElTitleA = $('<a style="color: #005fb4;"></a>').attr({href:hostname+"/torrent/"+id, target:"_blank",title:linkText}).text(linkText),
  686. FavElTitle = $(`<div ${isExists?'class="activExists '+(isExists=='NO'? 'activExistsRed':'')+'" data-exists="'+isExists+'"':''} style="display: table-cell;vertical-align: middle;padding:5px; width: 80%;position:relative;"></div>`).append(FavElTitleA,'<div class="class_category" style="position: absolute;top: -5px;left: 3px;color: #800047;font-size: 8px;font-weight: bold;background: #ffbbbb;padding: 0 5px;">'+category+'</div>'),
  687. FavAddBlock = $('<div style="display: table-cell;vertical-align: middle;padding:5px; width: 10%; border-left: 1px dotted orange;">'+
  688. '<div class="poleLinks"><a href="'+Down+'" target="_blank" title="Download"><img src="/s/i/d.gif" alt="Download"></a></div>'+
  689. '<div class="poleLinks"><a href="'+Mdown+'" target="_blank" title="Magnet Link"><img src="/s/i/m.png" alt="Magnet Link"></a></div>'+
  690. '<div class="poleLinks"><a href="'+hostname+"/search/"+encodeURIComponent(searchText)+'" target="_blank" title="Искать: '+linkText+'"><img src="'+searchIcon+'" alt="Искать:'+linkText+'" width="13"></a></div>'+
  691. '</div>'),
  692. FavElBlockX = $('<div title="Удалить!"></div>').text("X").click(function(e){
  693. let event_el = e.currentTarget,
  694. el_block = event_el.parentElement;
  695.  
  696. if(debug) console.log($(".mDiv_FavInner .FavBlockEl").index(el_block));
  697. removeFav({el:el_block, id:id, linkText:linkText, index:$(".mDiv_FavInner .FavBlockEl").index(el_block)});
  698. }),
  699. FavBlockEl = $('<div class="FavBlockEl"></div>').append(FavElTitle,FavAddBlock,FavElBlockX);
  700. FavBlockEl.on('mouseenter mouseleave', function(ev){
  701. $(this).first().toggleClass("blend_class")
  702. });
  703.  
  704. $(".mDiv_FavInner").append(FavBlockEl);
  705.  
  706. if($(".mDiv_FavInner").children().length === 0) {
  707. $(".mDiv_FavInner").empty();
  708. $(".mDiv_FavControl").fadeOut('slow');
  709. } else {
  710. $(".mDiv_FavControl").fadeIn('slow');
  711. }
  712.  
  713. $(".mDiv_title.fav").text('Избранное '+($(".mDiv_FavInner").children().length == 0 ?'':'('+$(".mDiv_FavInner").children().length+')'));
  714. }
  715.  
  716. async function addFav(param){
  717. let elem = param.el || null,
  718. link = param.link,
  719. linkText = param.linkText,
  720. Down = param.Down,
  721. Mdown = param.Mdown,
  722. date_time = param.date_time,
  723.  
  724. id = link,
  725.  
  726. category = await getCategoryTorrent(param)
  727.  
  728. try{
  729. // Get id
  730. id = id.match(/.*torrent\/(\d+)\//i)[1];
  731. param.id = id;
  732. if(!id) id = link;
  733.  
  734. if(debug) console.log("Ид равен: ", id);
  735.  
  736. // Save local storage
  737. if (!ObjSave.hasOwnProperty('favorites')){
  738. ObjSave.favorites = [];
  739. }
  740.  
  741. if(!checkPovtor({id:id,linkText:linkText})){
  742. if(debug) console.log("Нет в базе избранного, сохраняю!");
  743.  
  744. fly.call(elem, ".mDiv_FavInner", 3, 3000)
  745.  
  746. ObjSave.favorites.push({
  747. el: null,
  748. link: encodeURI(link),
  749. linkText: escape(linkText),
  750. id: id,
  751. Down: encodeURI(Down),
  752. Mdown: encodeURI(Mdown),
  753. date_time: date_time,
  754. category: category
  755. });
  756.  
  757. saveToStorage();
  758. //MakeFav(param); -> GM_addValueChangeListener update auto
  759.  
  760. showMessage('Избранное',`<p>Успешно добавлен в избранное!</p><p><b>${linkText}<b></p>`)
  761. }
  762. } catch (e){
  763. console.log(e);
  764. }
  765. }
  766.  
  767. function revomeFavAll(){
  768. if(confirm(`Вы действительно хотите очистить список избранного?`)){
  769. if (ObjSave.hasOwnProperty('favorites') && Object.keys(ObjSave.favorites).length){
  770. ObjSave.favorites = [];
  771. $(".mDiv_FavInner").empty().text('Пусто...');;
  772. saveToStorage();
  773. if(debug) console.log("Все элементы удалены из избранного!");
  774. $(".mDiv_title.fav").text('Избранное '+($(".mDiv_FavInner").children().length == 0 ?'':'('+$(".mDiv_FavInner").children().length+')'));
  775. $(".mDiv_FavControl").fadeOut('slow')
  776. }
  777. }
  778. }
  779.  
  780. function removeFav(param){
  781. let el = param.el,
  782. id = param.id,
  783. linkText = param.linkText,
  784. index = param.index;
  785.  
  786. if(confirm(`Вы действительно хотите удалить?\n"${linkText}"?`)){
  787. if (ObjSave.hasOwnProperty('favorites') && index !== "" && index !== null && index !== undefined){
  788. $(el).animate({"height":"0px","opacity": "0"},'slow', function(){
  789. ObjSave.favorites.splice(index, 1);
  790. $(this).remove();
  791. saveToStorage();
  792. if(debug) console.log("Элемент удален из избранного!");
  793. $(".mDiv_title.fav").text('Избранное '+($(".mDiv_FavInner").children().length == 0 ?'':'('+$(".mDiv_FavInner").children().length+')'));
  794.  
  795. if(!Object.keys(ObjSave.favorites).length) {
  796. $(".mDiv_FavInner").text('Пусто...');
  797. $(".mDiv_FavControl").fadeOut('slow')
  798. } else {
  799. $(".mDiv_FavControl").fadeIn('slow')
  800. }
  801. });
  802. }
  803. }
  804. }
  805.  
  806. function checkPovtor(params){
  807. let povtor = false,
  808. linkText = params.linkText,
  809. id = params.id
  810.  
  811. if (ObjSave.hasOwnProperty('favorites')){
  812. if(ObjSave.favorites.length > 0){
  813. for(var i=0; i<ObjSave.favorites.length;i++){
  814. let current = ObjSave.favorites[i]
  815. if(current.id === id){
  816. if(debug) console.log("Уже есть в базе избранного!");
  817. showMessage('Внимание',`<p>Уже есть в базе избранного!</p><p><b>${linkText}<b></p>`)
  818. povtor = true;
  819. }
  820. }
  821. }
  822. }
  823.  
  824. return povtor;
  825. }
  826.  
  827. function updateForm(){
  828. if (ObjSave.hasOwnProperty('options')){
  829. let chechVal = null,
  830. timoutTimeImages = 5;
  831. if (ObjSave.options.hasOwnProperty('preload')) chechVal = ObjSave.options.preload;
  832.  
  833. $("#checkbox_imgages_Load")[0].checked = chechVal;
  834.  
  835. timoutTimeImages = (ObjSave.options.hasOwnProperty('TimeOutLoadImages') && typeof(ObjSave.options.TimeOutLoadImages) == "number")?ObjSave.options.TimeOutLoadImages:5;
  836. $("#timoutTimeImages").val(timoutTimeImages);
  837. }
  838. }
  839.  
  840. function updateFav(){
  841. if(!ObjSave.options?.settings_visible?.fav) return
  842.  
  843. if (ObjSave.hasOwnProperty('favorites')){
  844. if(ObjSave.favorites.length > 0){
  845. $(".mDiv_FavInner").empty();
  846. for(let pFav = 0; pFav<ObjSave.favorites.length; pFav++){
  847. let ObjFavCur = ObjSave.favorites[pFav];
  848.  
  849. MakeFav({
  850. el: null,
  851. link: decodeURI(ObjFavCur.link),
  852. linkText: unescape(ObjFavCur.linkText),
  853. Down: decodeURI(ObjFavCur.Down),
  854. id: ObjFavCur.id,
  855. Mdown: decodeURI(ObjFavCur.Mdown),
  856. date_time: ObjFavCur.date_time,
  857. category: ObjFavCur.category,
  858. index: pFav,
  859. object: ObjFavCur
  860. });
  861. }
  862. }
  863. }
  864. }
  865.  
  866. function showMessage(title = "Сообщение", message, anim_time_sec = 1000, time_delay_sec = 3000, autohide=true){
  867. $(".mDiv_Popup_message_box > .mDiv_Popup_message").html(message);
  868. $(".mDiv_Popup > .mDiv_Popup_title span").text(title);
  869.  
  870. $(".mDiv_Popup_smoke").fadeIn(anim_time_sec, function(){
  871. $(".mDiv_Popup").fadeIn(anim_time_sec,function(){
  872. if(autohide){
  873. let anim = function (){$(this).fadeOut(anim_time_sec, function(){$(".mDiv_Popup_smoke").fadeOut(anim_time_sec);});}.bind(this);
  874. setTimeout(anim, time_delay_sec)
  875. }
  876. });
  877. });
  878. }
  879.  
  880. function searchinHost(search){
  881. return location.href.includes(search);
  882. }
  883.  
  884. function makePanel(){
  885. if(!document.getElementById("sidebar")) return;
  886.  
  887. if (!ObjSave.options.hasOwnProperty('settings_visible')){
  888. ObjSave.options.settings_visible = {
  889. sett:true,
  890. fav:true,
  891. opens:true,
  892. stream:true
  893. }
  894. } else if(typeof ObjSave.options.settings_visible == 'boolean'){
  895. ObjSave.options.settings_visible = {
  896. sett:true,
  897. fav:true,
  898. opens:true,
  899. stream:true
  900. }
  901. }
  902. if(debug)console.log('Menu show-hide: ',ObjSave.options.settings_visible)
  903.  
  904. let hostisT = searchinHost("/torrent/"),
  905. settings_visible = ObjSave.options.settings_visible,
  906. div = $('<div class="mDiv">'+
  907. (!hostisT?
  908. '<div class="mDiv_title'+(settings_visible.sett?'':' no_vis')+' sett">Настройки</div>'+
  909. '<div class="mDiv_settings_body mDiv_plugins" style="'+(settings_visible.sett?'display: block':'display: none')+'">'+
  910. '<div id="preLoadImages" class="imgages_Load">'+
  911. '<div class="preLoadImagesRow">'+
  912. '<div class="preLoadImagesCell">Предзагрузка: </div>'+
  913. '<div class="preLoadImagesCell" style="position:relative;"><input type="checkbox" class="checkbox_Load" id="checkbox_imgages_Load"><label for="checkbox_imgages_Load"></label></div>'+
  914. '</div>'+
  915. '<div class="preLoadImagesRow">'+
  916. '<div class="preLoadImagesCell">Тайм-аут загр.</div>'+
  917. '<div class="preLoadImagesCell"><input type="number" id="timoutTimeImages" title="Тайм-аут загрузки изображений.\nЕсли 0, то тайм-аут устанавл. настройкой браузера!" min="0" step="0.1"> сек.</div>'+
  918. '</div>'+
  919. '</div>'+
  920. '<div class="mDiv_title'+(settings_visible.stream?'':' no_vis')+' stream">Torrent Stream</div>'+
  921. '<div class="mDiv_settings_body imgages_Load" style="'+(settings_visible.stream?'display: block':'display: none')+'">'+
  922. '<div class="preLoadImagesRow">'+
  923. '<div class="preLoadImagesCell">TorrServer Ip:Port</div>'+
  924. '<div class="preLoadImagesCell"><input style="width: 150px;text-align:center;transform: scale(0.9);" id="torr_server_address" data-service="TorrServer" title="TorrServer адресс и порт" value="localhost:8090"></div>'+
  925. '</div>'+
  926. '<div class="preLoadImagesRow">'+
  927. '<div class="preLoadImagesCell">AceStream Ip:Port</div>'+
  928. '<div class="preLoadImagesCell"><input style="width: 150px;text-align:center;transform: scale(0.9);" id="acestream_server_address" data-service="AceStream" title="AceStream адресс и порт" value="localhost:6878"></div>'+
  929. '</div>'+
  930. '<div style="display:block;padding:2px;color:darkslateblue;font-size: 0.8rem;">Альфа версия: Нужен запущенный TorrServer или AceStream(лучше TorrServer😀) и запущенный <a href="https://github.com/AlekPet/Rutor-Preview-Ajax/tree/master/servers/nodejs">сервер</a>.</div>'+
  931. '</div>'+
  932. '<div class="mDiv_title'+(settings_visible.opens?'':' no_vis')+' opens">Открытые</div>'+
  933. '<div class="mDiv_settings_body" style="'+(settings_visible.opens?'display: block':'display: none')+'">'+
  934. '<div id="hideAll" class="buttonsStyle">Свернуть все</div>'+
  935. '<div class="mDiv_inner"></div>'+
  936. '</div>'+
  937. '<div class="mDiv_title'+(settings_visible.fav?'':' no_vis')+' fav">Избранное</div>'+
  938. '<div class="mDiv_settings_body" style="'+(settings_visible.fav?'display: block':'display: none')+'">'+
  939. '<div class="mDivFavControl_box">'+
  940. '<div class="mDiv_FavControl buttonsStyle" title="Очистить список избранного!">Очистить избранное</div>'+
  941. '<div class="mDiv_FavControlCheck buttonsStyle" title="Проверить торренты">Проверить торренты</div>'+
  942. '</div>'+
  943. '<div class="mDiv_FavInner"></div>'+
  944. '</div>'+
  945. '</div>': /* One torrent */
  946. '<div class="mDiv_title'+(settings_visible.sett?'':' no_vis')+' sett">Настройки</div>'+
  947. '<div class="mDiv_settings_body mDiv_plugins" style="'+(settings_visible.sett?'display: block':'display: none')+'">'+
  948. '<div id="preLoadImages" class="imgages_Load">'+
  949. '</div>'+
  950. '<div class="mDiv_title'+(settings_visible.stream?'':' no_vis')+' stream">Torrent Stream</div>'+
  951. '<div class="mDiv_settings_body imgages_Load" style="'+(settings_visible.stream?'display: block':'display: none')+'">'+
  952. '<div class="preLoadImagesRow" style="color:#b40000;">'+
  953. '<div class="preLoadImagesCell">TorrServer Ip:Port</div>'+
  954. '<div class="preLoadImagesCell"><input style="width: 150px;text-align:center;transform: scale(0.9);" id="torr_server_address" data-service="TorrServer" title="TorrServer адресс и порт" value="localhost:8090"></div>'+
  955. '</div>'+
  956. '<div class="preLoadImagesRow">'+
  957. '<div class="preLoadImagesCell">AceStream Ip:Port</div>'+
  958. '<div class="preLoadImagesCell"><input style="width: 150px;text-align:center;transform: scale(0.9);" id="acestream_server_address" data-service="AceStream" title="AceStream адресс и порт" value="localhost:6878"></div>'+
  959. '</div>'+
  960. '<div style="display:block;padding:2px;color:darkslateblue;font-size: 0.8rem;">Альфа версия: Нужен запущенный TorrServer или AceStream(лучше TorrServer😀) и запущенный <a href="https://github.com/AlekPet/Rutor-Preview-Ajax/tree/master/servers/nodejs">сервер</a>.</div>'+
  961.  
  962. '</div>'+
  963. '<div class="mDiv_title'+(settings_visible.opens?'':' no_vis')+' opens">Открытые</div>'+
  964. '<div class="mDiv_settings_body" style="'+(settings_visible.opens?'display: block':'display: none')+'">'+
  965. '<div id="hideAll" class="buttonsStyle">Свернуть все</div>'+
  966. '<div class="mDiv_inner"></div>'+
  967. '</div>'+
  968. '<div class="mDiv_title'+(settings_visible.fav?'':' no_vis')+' fav">Избранное</div>'+
  969. '<div class="mDiv_settings_body" style="'+(settings_visible.fav?'display: block':'display: none')+'">'+
  970. '<div class="mDiv_FavControl buttonsStyle" title="Очистить список избранного!">Очистить избранное</div>'+
  971. '<div class="mDivFavControl_box">'+
  972. '<div class="mDiv_FavControl buttonsStyle" title="Очистить список избранного!">Очистить избранное</div>'+
  973. '<div class="mDiv_FavControlCheck buttonsStyle" title="Проверить торренты">Проверить торренты</div>'+
  974. '</div>'+
  975. '<div class="mDiv_FavInner"></div>'+
  976. '</div>'+
  977. '</div>'+
  978. '</div>'+
  979. '</div>')+
  980. '</div>'),
  981.  
  982. chechVal = "";
  983. if (ObjSave.hasOwnProperty('options') && ObjSave.options.hasOwnProperty('preload')){
  984. chechVal = ObjSave.options.preload;
  985. }
  986.  
  987. $(div).find("#checkbox_imgages_Load").change(function(){
  988. if(debug) console.log("Предзагрузка: ",$(this)[0].checked);
  989.  
  990. if (ObjSave.hasOwnProperty('options')){
  991. if (!ObjSave.options.hasOwnProperty('preload')) ObjSave.options.preload = "";
  992. ObjSave.options.preload = $(this)[0].checked;
  993. saveToStorage();
  994. }
  995. }).attr("checked",chechVal);
  996.  
  997. $(div).find("#timoutTimeImages").change(function(){
  998. let valueTO = $(this).val();
  999.  
  1000. if(debug) console.log("Тайм-аут установлен в: ", valueTO+" сек.");
  1001.  
  1002. if(valueTO === "" || /^\s?$/.test(valueTO)) $(this).val(5);
  1003.  
  1004. if (ObjSave.hasOwnProperty('options')){
  1005. if (!ObjSave.options.hasOwnProperty('TimeOutLoadImages')) ObjSave.options.TimeOutLoadImages = 5;
  1006. TimeOutImages = ObjSave.options.TimeOutLoadImages = parseFloat($(this).val());
  1007. saveToStorage();
  1008. }
  1009. }).val((ObjSave.options.TimeOutLoadImages)?ObjSave.options.TimeOutLoadImages:5);
  1010.  
  1011. // TorrServ & AceStream
  1012.  
  1013. $(div).find("#torr_server_address, #acestream_server_address").on('change',function(){
  1014. let valueInput = $(this).val(),
  1015. service = this.dataset.service,
  1016. options_service_name = service === 'TorrServer' ? ['torr_server_address', torr_serv_port] : ['acestream_server_address', acestream_port],
  1017. checkAddr = valueInput.match(/(localhost|\b\d{1,3}\b\.\b\d{1,3}\b\.\b\d{1,3}\b\.\b\d{1,3}\b)\:\b(\d+)\b/g),
  1018. prevVal = $(this).data('preVal')
  1019.  
  1020. if(!checkAddr) {
  1021. alert(`Адресс ${service}\'а указан неверно!`)
  1022. $(this).val(prevVal ? prevVal : 'localhost:'+options_service_name[1])
  1023. return;
  1024. }
  1025.  
  1026. $(this).data('preVal', valueInput)
  1027.  
  1028. if (ObjSave.hasOwnProperty('options')){
  1029. ObjSave.options[options_service_name[0]] = checkAddr && checkAddr.length==1 ? checkAddr[0] : 'localhost:'+options_service_name[1];
  1030. }
  1031. saveToStorage();
  1032.  
  1033. }).val(function(index, value){
  1034. const options_service_name = this.dataset.service === 'TorrServer' ? ['torr_server_address', torr_serv_port] : ['acestream_server_address', acestream_port]
  1035. return ObjSave.options[options_service_name[0]] ? ObjSave.options[options_service_name[0]] : 'localhost:'+options_service_name[1]
  1036. })
  1037.  
  1038. $("#sidebar").append(div);
  1039.  
  1040. $("#sidebar .mDiv").click(function(event){
  1041. const target = event.target
  1042. if(target.classList.contains('mDiv_title') /*&& !target.classList.contains('sett')*/){
  1043. const nameSp = target.classList[target.classList.length-1],
  1044. settings_body = $(target.nextElementSibling),
  1045. $traget = $(target)
  1046.  
  1047. if (settings_body.css('display') == 'none'){
  1048. if(nameSp === 'fav' && $('.mDiv_FavInner').children().length === 0) updateFav()
  1049. settings_body.slideDown('slow')
  1050. ObjSave.options.settings_visible[nameSp] = true
  1051. $traget.removeClass('no_vis')
  1052.  
  1053. } else {
  1054. settings_body.slideUp('slow')
  1055. ObjSave.options.settings_visible[nameSp] = false
  1056. $traget.removeClass(nameSp)
  1057. $traget.addClass('no_vis')
  1058. $traget.addClass(nameSp)
  1059. }
  1060. saveToStorage();
  1061. }
  1062.  
  1063. })
  1064.  
  1065. if(ObjSave.hasOwnProperty('favorites') && Object.keys(ObjSave.favorites).length > 0) {
  1066. $(".mDiv_FavInner").fadeIn('slow');
  1067. $(".mDiv_FavControl").fadeIn('slow');
  1068. } else{
  1069. $(".mDiv_FavInner").text('Пусто...').fadeIn('slow');
  1070. $(".mDiv_FavControl").fadeOut('slow');
  1071. }
  1072.  
  1073. let maxTop = $(".sideblock:nth-child(1)").offset().top+parseFloat($(".sideblock:nth-child(1)").css("height"))+parseFloat($(".sideblock:nth-child(2)").css("height"));
  1074. $(window).scroll(function() {
  1075. if($(window).scrollTop() >= maxTop){
  1076. $(".sideblock:eq(1)").css({"position":"fixed", "top":"0px","width":"250px"});
  1077. $(".mDiv").css({"position":"fixed", "top":"70px"});
  1078. } else {
  1079. $(".mDiv").add($(".sideblock:eq(1)")).removeAttr("style");
  1080. }
  1081. });
  1082.  
  1083. $("#hideAll").click(function(){
  1084. if($(".my_tr:visible").length){
  1085. $(".my_tr").fadeOut("slow", function(){
  1086. $("img.butSpoiler").css("transform", "scaleY(1)").attr("title","Показать раздачу");
  1087.  
  1088. // Remove see
  1089. $("#hideAll").fadeOut("fast", function(){
  1090. $(".mDiv_title.opens").hide();
  1091. $(".mDiv_inner").empty();
  1092. });
  1093.  
  1094. });
  1095. }
  1096. }).hide();
  1097.  
  1098. $(".mDiv_FavControl").click(revomeFavAll);
  1099. $(".mDiv_FavControlCheck").click(torrentsFavoritesExists);
  1100.  
  1101. appendSmokeAndPopUp()
  1102. }
  1103.  
  1104. function appendSmokeAndPopUp(){
  1105. $("body").append($('<div class="mDiv_Popup_smoke">'+
  1106. '<div class="mDiv_Popup">'+
  1107. '<div class="mDiv_Popup_title"><span></span><div class="mDiv_Popup_title_x"></div></div>'+
  1108. '<div class="mDiv_Popup_message_box">'+
  1109. '<div class="mDiv_Popup_message"></div>'+
  1110. '</div>'+
  1111. '</div>'));
  1112. $('.mDiv_Popup_title_x').click(function(){
  1113. $(".mDiv_Popup").fadeOut(1000, function(){$(".mDiv_Popup_smoke").fadeOut(1000);});
  1114. });
  1115. }
  1116.  
  1117. function searchEditReq(title){
  1118. let seatchText = title.match(/(.*)(?:\(|\[)/i)[1];
  1119.  
  1120. if(seatchText === null || seatchText === undefined || !seatchText.length) seatchText = title;
  1121.  
  1122. if(seatchText.indexOf("/") !=-1 || seatchText.indexOf("\\")!=-1){
  1123. seatchText = seatchText.replace(/\s?\/\s?|\s?\\\s?/g," ")
  1124. }
  1125. return seatchText;
  1126. }
  1127.  
  1128. function fly(target, size, duration){
  1129. target = $(target)
  1130.  
  1131. if($('.mDiv_settings_body').css('display') == 'none') target = $('.mDiv_title')
  1132.  
  1133. let posLeft = target.offset().left-$(this).offset().left,
  1134. posTop = target.offset().top-($(this).offset().top+target.height()/2)
  1135.  
  1136. $(this).
  1137. clone()
  1138. .css({
  1139. "position":"absolute",
  1140. "z-index":"9999999999",
  1141. "filter": "hue-rotate(270deg)",
  1142. "text-indent": "0px"
  1143. })
  1144. .appendTo(this)
  1145. .animate(
  1146. {
  1147. left:"+="+posLeft,
  1148. top:"+="+posTop,
  1149. textIndent: size
  1150. },
  1151. {
  1152. step: function( now, fx ) {
  1153. $(this).css("transform","scale("+now+")")
  1154. },
  1155. duration: duration,
  1156. complete: function(){
  1157. $(this).remove()
  1158. }
  1159. }
  1160. )
  1161. }
  1162.  
  1163. function convertSizes(bytes, poslezap = 2){
  1164. if (bytes === 0) return '0 Bytes';
  1165.  
  1166. const k = 1024,
  1167. dm = poslezap < 0 ? 0 : poslezap,
  1168. sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  1169. i = Math.floor(Math.log(bytes) / Math.log(k));
  1170.  
  1171. return parseFloat((bytes / Math.pow(k, i)).toFixed(poslezap)) + ' ' + sizes[i];
  1172. }
  1173.  
  1174. // -- TorrServer
  1175. function checkRunningService(params){}
  1176.  
  1177. function requestTorrentService(params){
  1178.  
  1179. const method = params.method ? params.method : 'GET',
  1180. data = method == 'POST' && params.data ? params.data : ''
  1181.  
  1182. return new Promise((resolve, reject)=>{
  1183.  
  1184. GM.xmlHttpRequest({
  1185. method: method,
  1186. url: params.url,
  1187. data: data,
  1188. responseType: 'json',
  1189. headers : { 'Content-type' : 'application/json' },
  1190. onload: function(res) {
  1191. if(res.status == 200 && res.statusText == 'OK'){
  1192. resolve({status:'OK', data: res.response})
  1193. } else if(res.status == 403) {
  1194. resolve({status: 'error_403'})
  1195. } else {
  1196. reject(`[Status ${res.status}] Запрос вернул ошибку...`)
  1197. }
  1198. },
  1199. onerror: function(e){
  1200. reject('[Request] Запрос вернул ошибку...')
  1201. }
  1202. })
  1203. })
  1204. }
  1205.  
  1206. async function torrServAction(down, torr_server_address, save=true){
  1207. try{
  1208. const issave = save ? '&save' : '',
  1209. {status, data} = await requestTorrentService({url: `http://${torr_server_address}/stream/fname?link=${down}${issave}&stat`})
  1210.  
  1211. if(status == 'OK'){
  1212. return data
  1213. } else if(status == 'error_403') {
  1214. showMessage('ОШИБКА',`<p style='color:red; font-weight: bold;'>Запрошенный URL не может быть получен, проверьте работает ли TorServer!</p>`)
  1215. return null
  1216. }
  1217. }
  1218. catch(ev) {
  1219. showMessage('ОШИБКА',`<p style='color:red; font-weight: bold;'>TorrServ не работает (адрес <span style='color: blue;'>${torr_server_address}</span>) или ошибка в коде!</p><p>Текст ошибки: '${ev}'</p>`)
  1220. }
  1221. }
  1222.  
  1223. function returnIframe(v,addr,v_name,vhash,vindex=1,){
  1224. v.empty()
  1225. //const isvideo = /\.(?:mp4|mkv|avi|m3u8)$/g.test(v_name) ? {style: 'position: absolute; width: 100%;height: 100%;top: 0;left: 0;border:none;'} : {style: 'width:100%;border:none;overflow:hidden;'},
  1226. const addr_path = encodeURIComponent(`http://${addr}/stream/fname?link=${vhash}`),
  1227. serverHTTP = 'http://localhost:8000/frame' // 'http://alekpet.pythonanywhere.com/getvideo' // http://localhost:8000/frame
  1228. return `<iframe src="${serverHTTP}?path_vid=${addr_path}&name_vid=${encodeURIComponent(v_name)}&index_vid=${vindex}" frameborder="0" scrolling="no" />` //style="${isvideo.style}"
  1229. }
  1230.  
  1231. async function torrServer(params){
  1232.  
  1233. const {down, magn, linkText, action='add'} = params,
  1234. torr_server_address = $("#torr_server_address").val()
  1235.  
  1236. if(!torr_server_address){
  1237. alert(`Адрес TorrServer\'а '${torr_server_address}' указан неверно!`)
  1238. return
  1239. }
  1240.  
  1241. try{
  1242. if(action == 'add'){
  1243. if(confirm(`Добавить "${linkText}" для проигрывания в torrServ?`)){
  1244. const data = await torrServAction(magn, torr_server_address)
  1245. if(data){
  1246. showMessage('УСПЕШНО',`<p style='color:green;'><b>Торрент был сохранен в TorServer!</b></p>
  1247. <p><b>Название:</b> ${data.title || data.name}</p>
  1248. <p><b>Размер:</b> ${convertSizes(data.torrent_size)}</p>`)
  1249. }
  1250. }
  1251. } else if(action == 'play'){
  1252. const data = await torrServAction(magn, torr_server_address, false)
  1253. if(data){
  1254. if(confirm('Запустить проигрыватель?')){
  1255.  
  1256. let videos = data.file_stats.filter((elem, idx)=> /.(avi|mp4|mkv|mp3)/g.test(elem.path)),
  1257. boxPlayer = $('#torrentPlayer'),
  1258. close_vid,inner_vid,inner_list,vid_info,vid_title = null
  1259.  
  1260. if(boxPlayer.length) boxPlayer.remove()
  1261.  
  1262. boxPlayer = $("<div></div>").attr('id','torrentPlayer')
  1263.  
  1264. close_vid = $("<div class='torrentPlayer_close'>").attr('title','Закрыть').text('X').click(function(){
  1265. boxPlayer.hide(()=>{
  1266. boxPlayer.remove()
  1267. })
  1268. })
  1269. vid_title = $("<div class='torrentPlayer_title'>")
  1270. vid_info = $("<div class='torrentPlayer_info'>").text('Загрузка...')
  1271. inner_vid = $("<div class='torrentPlayer_video'>")
  1272. inner_list = $("<div class='torrentPlayer_list'>")
  1273.  
  1274. vid_title.append(vid_info,close_vid)
  1275.  
  1276. boxPlayer.append(vid_title,inner_vid,inner_list)
  1277. $('body').append(boxPlayer)
  1278.  
  1279. if(videos.length){
  1280. let frame = returnIframe(inner_vid, torr_server_address, videos[0].path, data.hash)
  1281. inner_vid.append(frame)
  1282.  
  1283. let ulpl = $("<ul class='torrentPlayer_playlist'></ul>")
  1284. vid_info.text(videos[0].path)
  1285.  
  1286. for(let [k,v] of videos.entries()){
  1287. let li = $("<li></li>").click(function(){
  1288. let frame = returnIframe(inner_vid, torr_server_address, v.path, data.hash, v.id)
  1289. inner_vid.html(frame)
  1290. vid_info.text(v.path)
  1291. }),
  1292. title_item_list = `${k+1}. ${v.path}`,
  1293. name_vid = $("<span class='torrentPlayer_playlist_item_title'>").text(title_item_list),
  1294. size_vid = $("<span class='torrentPlayer_playlist_item_size'>").text(convertSizes(v.length))
  1295.  
  1296. li.append(name_vid,size_vid)
  1297. ulpl.append(li)
  1298. }
  1299.  
  1300. inner_list.append(ulpl)
  1301. }
  1302. }
  1303. }
  1304. }
  1305. } catch(ev) {
  1306. showMessage('ОШИБКА',`<p style='color:red; font-weight: bold;'>Текст ошибки: '${ev}'</p>`)
  1307. }
  1308. }
  1309. // -- TorrServer
  1310.  
  1311. // -- AceStream
  1312. async function AceStreamAction(down, acestream_server_address, save=true){
  1313. try{
  1314. const issave = save ? '&save' : '',
  1315. {status, data} = await requestTorrentService({url: `http://${acestream_server_address}/server/api?method=get_api_access_token`})
  1316.  
  1317. if(status == 'OK'){
  1318. return data.result
  1319. } else if(status == 'error_403') {
  1320. showMessage('ОШИБКА',`<p style='color:red; font-weight: bold;'>Запрошенный URL не может быть получен, проверьте работает ли AceStream!</p>`)
  1321. return null
  1322. }
  1323. }
  1324. catch(ev) {
  1325. showMessage('ОШИБКА',`<p style='color:red; font-weight: bold;'>AceStream не работает (адрес <span style='color: blue;'>${acestream_server_address}</span>) или ошибка в коде!</p><p>Текст ошибки: '${ev}'</p>`)
  1326. }
  1327. }
  1328.  
  1329. async function aceStreamServer(params){
  1330. const {down, magn, linkText, action='play'} = params,
  1331. acestream_server_address = $("#acestream_server_address").val()
  1332.  
  1333. if(!acestream_server_address){
  1334. alert(`Адрес AceStream\'а '${acestream_server_address}' указан неверно!`)
  1335. return
  1336. }
  1337.  
  1338. // http://127.0.0.1:6878/ace/getstream?url=http://d.rutor.info/download/894977
  1339. // http://127.0.0.1:6878/ace/manifest.m3u8?url=http://d.rutor.info/download/894977&format=json
  1340. // http://localhost:6878/server/api?method=get_api_access_token
  1341. const {token} = await AceStreamAction(magn, acestream_server_address, false)
  1342.  
  1343. if(token){
  1344. if(confirm('Запустить проигрыватель?')){
  1345.  
  1346. let videos = encodeURIComponent(`http://${acestream_server_address}/ace/getstream?url=${down}`),
  1347. boxPlayer = $('#torrentPlayer'),
  1348. close_vid,inner_vid,inner_list,vid_info,vid_title = null
  1349.  
  1350. if(boxPlayer.length) boxPlayer.remove()
  1351.  
  1352. boxPlayer = $("<div></div>").attr('id','torrentPlayer')
  1353.  
  1354. close_vid = $("<div class='torrentPlayer_close'>").text('X').click(function(){
  1355. boxPlayer.hide(()=>{
  1356. boxPlayer.remove()
  1357. })
  1358. })
  1359. vid_title = $("<div class='torrentPlayer_title'>")
  1360. vid_info = $("<div class='torrentPlayer_info'>").text('Загрузка...')
  1361. inner_vid = $("<div class='torrentPlayer_video'>")
  1362. inner_list = $("<div class='torrentPlayer_list'>")
  1363.  
  1364. vid_title.append(vid_info,close_vid)
  1365.  
  1366. boxPlayer.append(vid_title,inner_vid,inner_list)
  1367. $('body').append(boxPlayer)
  1368.  
  1369. if(videos.length){
  1370. inner_vid.empty()
  1371. let frame = `<iframe src="http://localhost:8000/frame?path_vid=${videos}&name_vid=${encodeURIComponent(linkText)}&index_vid=${1}" frameborder="0" scrolling="no" style="width: 100%;height: 100%;" />`
  1372. inner_vid.append(frame)
  1373.  
  1374. let ulpl = $("<ul class='torrentPlayer_playlist'></ul>")
  1375. vid_info.text(linkText)
  1376.  
  1377. /*for(let v of videos){
  1378. let li = $("<li></li>").click(function(){
  1379. inner_vid.empty()
  1380. let frame = `<iframe src="http://localhost:8000/frame?path_vid=${v}&name_vid=${encodeURIComponent(v)}&index_vid=${v}" frameborder="0" scrolling="no"/>`
  1381. inner_vid.html(frame)
  1382. vid_info.text(v)
  1383. }),
  1384. name_vid = $("<span class='torrentPlayer_playlist_item_title'>").text(v),
  1385. size_vid = $("<span class='torrentPlayer_playlist_item_size'>").text(convertSizes(v.length))
  1386.  
  1387. li.append(name_vid,size_vid)
  1388. ulpl.append(li)
  1389. }
  1390.  
  1391. inner_list.append(ulpl)*/
  1392. }
  1393. }
  1394. }
  1395.  
  1396. }
  1397. // -- AceStream
  1398.  
  1399. function addPoleInfo(){
  1400. if(!searchinHost("/torrent/")){
  1401.  
  1402. // Ищим классы для получения данных
  1403. $(".backgr, .gai, .tum").each(function(i, val){
  1404. // Если класс заголовка добавляем свой заголовок для кнопки
  1405. if(this.className == "backgr") {
  1406. $('<td width="1px"></td>').prependTo(this);
  1407. } else {
  1408. // Если нет получаем информацию
  1409. let elem = this,
  1410. m_elem = elem.children[1],
  1411. link, linkText, magn, down, count_magnet = 1,
  1412.  
  1413. img = $('<img/>').attr({title:"Показать раздачу",class:"butSpoiler", src:image_arrow, alt:""}),
  1414. newI = $('<td/>').css("text-align","center").append(img);
  1415.  
  1416. if(m_elem.children[count_magnet] && m_elem.children[count_magnet].href.indexOf('magnet') == -1){
  1417. down = m_elem.children[1].href
  1418. link = m_elem.children[count_magnet] ? m_elem.children[count_magnet].href : null
  1419. linkText = m_elem.children[count_magnet] ? m_elem.children[count_magnet].textContent : null
  1420. } else {
  1421. down = m_elem.children[count_magnet-1].href
  1422. magn = m_elem.children[count_magnet] ? m_elem.children[count_magnet].href : null
  1423. link = m_elem.children[count_magnet+1] ? m_elem.children[count_magnet+1].href : null
  1424. linkText = m_elem.children[count_magnet+1] ? m_elem.children[count_magnet+1].textContent : null
  1425. }
  1426.  
  1427. let favorite = $("<a/>")
  1428. .attr({href:'javascript:void(0);', title:`Добавить в избранное:\nИмя: ${linkText}\nСсылка торрента: ${link}\nDownload: ${down}\nMagnet: ${(magn ? magn : 'Нет')}`, class:'downgif'})
  1429. .append($("<img/>").attr({src:favIcon, width:'13',alt:''}))
  1430. .click(function(ev){
  1431. ev.stopPropagation()
  1432. addFav({
  1433. el:this,
  1434. link:link,
  1435. linkText:linkText,
  1436. Down:down,
  1437. Mdown:magn,
  1438. date_time: new Date().getTime()
  1439. });
  1440. }),
  1441. search = $("<a/>")
  1442. .attr({href:'javascript:void(0);', title:`Искать: ${linkText}`, class:'downgif'})
  1443. .append($("<img/>").attr({src: searchIcon, width:'13', alt:''}))
  1444. .click(function(ev){
  1445. ev.stopPropagation()
  1446. let searchText = searchEditReq(linkText);
  1447. window.location.href = hostname+"/search/"+encodeURIComponent(searchText);
  1448. }),
  1449.  
  1450. AceStreamServPlay = $("<a/>")
  1451. .attr({href:'javascript:void(0);', title:`Проиграть в AceStream: ${linkText}`, class:'downgif service_splitter', 'data-servname':'AceStream'})
  1452. .append($('<span/>').text('AceStream'))
  1453. .append($("<img/>").attr({src: aceStreamIcon, width:'13', alt:''}))
  1454. .click(function(ev){
  1455. ev.stopPropagation()
  1456. aceStreamServer({down, linkText, magn, action: 'play'})
  1457. }) ,
  1458.  
  1459. torrServPlay = $("<a/>")
  1460. .attr({href:'javascript:void(0);', title:`Проиграть в torrserv: ${linkText}`, class:'downgif','data-servname':'TorrServ Play'})
  1461. .append($('<span>').text('TorrServ Play'))
  1462. .append($("<img/>").attr({src: torrServIcon, width:'13', alt:''}))
  1463. .click(function(ev){
  1464. ev.stopPropagation()
  1465. torrServer({down, linkText, magn, action: 'play'})
  1466. }),
  1467.  
  1468. torrServ = $("<a/>")
  1469. .attr({href:'javascript:void(0);', title:`Добавить в torrserv: ${linkText}`, class:'downgif','data-servname':'TorrServ Add'})
  1470. .append($('<span/>').text('TorrServ Add'))
  1471. .append($("<img/>").attr({src: torrServToAdd, width:'13', alt:''}))
  1472. .click(function(ev){
  1473. ev.stopPropagation()
  1474. torrServer({down, magn, linkText})
  1475. }),
  1476.  
  1477. pop_items = $("<div class='pop_elements'></div>"),
  1478. bufDiv = $("<a class='pop_panel' onclick='event.stopPropagation();'><img src='https://www.pvsm.ru/images/2019/10/14/v-zakladki-PDF-i-ePUB-versiya-rukovodstva-po-React-3.png' width='15' alt=''/></a>").append(pop_items)
  1479. pop_items.append(AceStreamServPlay,torrServPlay,torrServ)
  1480.  
  1481.  
  1482. // Image event
  1483. $(img).add(elem).click(async function(e) {
  1484. e.stopPropagation()
  1485.  
  1486. //if(e.target.tagName == 'A') return true
  1487.  
  1488. if(!$(elem).next().is(".tr_loading")){
  1489. $(elem).after('<tr class="tr_loading" style="text-align:center; display:none;"><td colspan="6">'+
  1490. '<div class="loading_tor_box">'+
  1491. '<div class="loading_tor"><div class="loading_tor_text"></div></div>'+
  1492. '</div>'+
  1493. '</td></tr>');
  1494. $(elem).next('.tr_loading').after('<tr class="my_tr"><td colspan="6"></td></tr>');
  1495.  
  1496. ajaxJQ({button : img , link: link, elem : elem}).then((data)=> modifyData(data));
  1497. } else {
  1498. ShowIHide({elem:elem, button: img, event_el: e.currentTarget.className});
  1499. }
  1500. });
  1501.  
  1502.  
  1503. $(m_elem).on('click contextmenu',function(ev){
  1504. const cur_ = ev.target
  1505. if(cur_ && /download|magnet|torrent/.test(cur_.parentElement.href) || cur_.tagName == 'A'){
  1506. ev.stopPropagation()
  1507. }
  1508. });
  1509.  
  1510. favorite.insertBefore(m_elem.children[0])
  1511. search.insertBefore(m_elem.children[0])
  1512. bufDiv.insertBefore(m_elem.children[0])
  1513. newI.prependTo(this);
  1514. }
  1515. });
  1516. } else {
  1517. const poleDown = $("#download a"),
  1518. link = location.href,
  1519. linkText = $("#all > h1").text(),
  1520. down = poleDown.eq(1).attr('href'),
  1521. magn = poleDown.eq(0).attr('href'),
  1522.  
  1523. box_buttons = $("<div class='box_buttons_inner'></div>").insertAfter(poleDown.eq(1)),
  1524.  
  1525. favorite = $("<a href='javascript:void(0);' title='Добавить в избранное'><img src='"+favIcon+"' width='15'></a>").click(function(){
  1526. addFav({
  1527. el:this,
  1528. link:link,
  1529. linkText:linkText,
  1530. Down:down,
  1531. Mdown:magn,
  1532. date_time: new Date().getTime()
  1533. });
  1534. }),
  1535. search = $("<a href='javascript:void(0);' style='margin-left:10px;' title='Искать: "+linkText+"'><img src='"+searchIcon+"' width='15'></a>").click(function(){
  1536. let searchText = searchEditReq(linkText);
  1537. window.location.href = hostname + "/search/"+encodeURIComponent(searchText);
  1538. }),
  1539.  
  1540. AceStreamServPlay = $("<a/>")
  1541. .css('margin-left','10px')
  1542. .attr({href:'javascript:void(0);', title:`Проиграть в AceStream: ${linkText}`})
  1543. .append($("<img/>").attr({src: aceStreamIcon, width:'15', alt:''}))
  1544. .click(function(ev){
  1545. ev.stopPropagation()
  1546. aceStreamServer({down, linkText, magn, action: 'play'})
  1547. }) ,
  1548. torrServPlay = $("<a/>")
  1549. .css('margin-left','10px')
  1550. .attr({href:'javascript:void(0);', title:`Проиграть в torrserv: ${linkText}`})
  1551. .append($("<img/>").attr({src: torrServIcon, width:'15', alt:''}))
  1552. .click(function(ev){
  1553. ev.stopPropagation()
  1554. torrServer({down, linkText, magn, action: 'play'})
  1555. }),
  1556.  
  1557. torrServ = $("<a/>")
  1558. .css('margin-left','10px')
  1559. .attr({href:'javascript:void(0);', title:`Добавить в torrserv: ${linkText}`})
  1560. .append($("<img/>").attr({src: torrServToAdd, width:'15', alt:''}))
  1561. .click(function(ev){
  1562. ev.stopPropagation()
  1563. torrServer({down, magn, linkText})
  1564. })
  1565.  
  1566. favorite.appendTo(box_buttons)
  1567. search.appendTo(box_buttons)
  1568. torrServPlay.appendTo(box_buttons)
  1569. torrServ.appendTo(box_buttons)
  1570. AceStreamServPlay.appendTo(box_buttons)
  1571. }
  1572. }
  1573.  
  1574. async function getCategoryTorrent(currentObj){
  1575. let category_ ="Нет категории"
  1576. await new Promise(function(res,rej){
  1577. $.ajax({
  1578. url: currentObj.link,
  1579. success: function(data){
  1580. try{
  1581. category_ = data.match(/Категория.*\>(.*)\<\/a/i)[1]
  1582. }
  1583. catch(e){
  1584. if(debug)console.warn(`Категория не найдена у: ${unescape(currentObj.linkText)}... (Раздача не существует)`)
  1585. }
  1586. res(category_)
  1587. },
  1588. error: function(e){
  1589. rej("Нет категории")
  1590. }
  1591.  
  1592. }).then(function(res){
  1593.  
  1594. })
  1595. })
  1596. if(debug) console.log(`Категория у '${unescape(currentObj.linkText)}' следующая '${category_!="Нет категории"?category_:'%cНет категории'}'`, "color:red")
  1597. return category_
  1598. }
  1599.  
  1600. function torrentsFavoritesExists(){
  1601. if(!confirm('Проверить торренты в избранном?')) return
  1602. // Check torrent exists?
  1603. let promises = []
  1604. for(let obj in ObjSave.favorites){
  1605. let currentObj = ObjSave.favorites[obj],
  1606.  
  1607. p = new Promise((res,rej)=>{
  1608. let v = currentObj.link.split('/')
  1609. $.ajax({
  1610. url: `/torrent/${v[v.length-1]}`,
  1611. success: (data) => {
  1612. let result = data.includes('Раздача не существует!')?false:true
  1613. return res({result, v:unescape(currentObj.linkText).trim()})
  1614. },
  1615. error: (e) => res({result: false, v})
  1616. })
  1617. }).then((result_)=>{
  1618. let {result, v} = result_
  1619. currentObj.isExists = (typeof result === 'string' ? JSON.parse(result): result)
  1620. return !result ? `Ссылка на торрент больше не существует: ${v}`: null
  1621. })
  1622. promises.push(p)
  1623. }
  1624.  
  1625. Promise.all(promises).then(values => {
  1626. let filter_vals = values.filter(v => v)
  1627. if(filter_vals.length){
  1628. alert(filter_vals.join('\n'))
  1629. console.log(`%c${filter_vals.join('\n')}`, 'color: orange;background:darkred;');
  1630. updateFav()
  1631. }
  1632. });
  1633.  
  1634. }
  1635.  
  1636. async function remakeFav(){
  1637. if (ObjSave.hasOwnProperty('favorites')){
  1638. // Favorites object
  1639. let isEdit = !1;
  1640.  
  1641. if(Object.prototype.toString.call(ObjSave.favorites) == "[object Object]"){
  1642. if(Object.keys(ObjSave.favorites).length > 0){
  1643. for(let pFav in ObjSave.favorites){
  1644. // no date
  1645. if(!ObjSave.favorites[pFav].hasOwnProperty("date_time")){
  1646. ObjSave.favorites[pFav].date_time = new Date().getTime()
  1647. if(debug) console.log("Нет Даты!: ", ObjSave.favorites[pFav])
  1648. }
  1649.  
  1650. // http
  1651. if(pFav.includes("http://")){
  1652. if(debug) console.log("Ид содержит http!: ", ObjSave.favorites[pFav])
  1653.  
  1654. let pFavencodeURI = encodeURI(pFav),
  1655. newId = unescape(pFav).match(/.*torrent\/(\d+)\//i)[1];
  1656.  
  1657. ObjSave.favorites[newId] = ObjSave.favorites[pFavencodeURI];
  1658. ObjSave.favorites[newId].id = newId;
  1659. delete ObjSave.favorites[pFavencodeURI]
  1660. }
  1661.  
  1662. }
  1663.  
  1664. }
  1665. // Favorites convert to array
  1666. ObjSave.favorites = Object.keys(ObjSave.favorites).map((k,i) => ({...ObjSave.favorites[k]}))
  1667. isEdit = !0;
  1668.  
  1669. if(debug) console.log("Исправленме Ид и добавление Даты: ",ObjSave,"Были ли правки:",isEdit)
  1670. saveToStorage();
  1671.  
  1672. } else{
  1673. if(!debug) console.log('Объект фаворит это массив...')
  1674. for(let obj=0;obj<ObjSave.favorites.length;obj++){
  1675. let currentObj = ObjSave.favorites[obj]
  1676.  
  1677. // no date
  1678. if(!currentObj.hasOwnProperty("date_time")){
  1679. currentObj.date_time = new Date().getTime()
  1680. if(debug) console.log("Нет Даты!: ", currentObj.date_time)
  1681. }
  1682.  
  1683. // http
  1684. if(currentObj.hasOwnProperty("link") && currentObj.hasOwnProperty("Down")){
  1685. let torrentId = currentObj.link
  1686. if(currentObj.link.includes("http://")){
  1687. if(debug) console.log("Link содержит http!: ", currentObj.link)
  1688. try{
  1689. torrentId = currentObj.link.match(/(\d+)\/?/i)[1];
  1690. } catch(e){
  1691. torrentId = currentObj.link//.match(/(\d+)/i)[1]
  1692. console.log('Remake Favorite no find ID', currentObj.link)
  1693. }
  1694. currentObj.link = `${hostname}/torrent/${torrentId}`
  1695. }
  1696.  
  1697. if(currentObj.Down.includes("http://")){
  1698. if(debug) console.log("Down содержит http!: ", currentObj.Down)
  1699. currentObj.Down = `http://d.${location.hostname}/download/${torrentId}`
  1700. }
  1701.  
  1702. if(debug) console.log('New link and download:', currentObj)
  1703. }
  1704.  
  1705. //---------- Category
  1706. if(!currentObj.hasOwnProperty('category')){
  1707. isEdit = !0;
  1708. let category_ = await getCategoryTorrent(currentObj)
  1709. currentObj.category = category_
  1710. }
  1711. //----------
  1712.  
  1713. }
  1714. }
  1715. if(debug) console.log('После remakeFav:', ObjSave.favorites)
  1716. if(isEdit){
  1717. saveToStorage();
  1718. console.log('Save remake...')
  1719. }
  1720. }
  1721. }
  1722.  
  1723. // Сортировка и корекция развернутых раздач
  1724. function correctSortRazdch(sortWhat, type, field, butIndx){
  1725. let dataClicked = sortWhat.sorti[butIndx].press,
  1726. __this = this,
  1727. press = this
  1728.  
  1729. sortWhat = Object.assign({}, sortWhat);
  1730.  
  1731. if(type == 0){
  1732. sortWhat.razd.sort(function(a,b) {
  1733. var an = a[field],
  1734. bn = b[field]
  1735. return an - bn;
  1736. });
  1737. } else if(type == 1){
  1738. sortWhat.razd.sort(function(a,b) {
  1739. var x = a[field].toLowerCase();
  1740. var y = b[field].toLowerCase();
  1741.  
  1742. if(x < y) return -1;
  1743. if(x > y) return 1;
  1744. return 0
  1745. });
  1746. }
  1747.  
  1748. if(dataClicked) sortWhat.razd.reverse()
  1749.  
  1750. for(var i=0; i<sortWhat.razd.length;i++){
  1751. let elDetach = $(sortWhat.razd[i].es),
  1752. childs = null
  1753.  
  1754. if(elDetach.next().next().is(".my_tr")) childs = [elDetach.next(),elDetach.next().next()]
  1755.  
  1756. elDetach.detach().appendTo(sortWhat.category)
  1757.  
  1758. if(childs != null){
  1759. $(childs[1]).detach().insertAfter(elDetach)
  1760. $(childs[0]).detach().insertAfter(elDetach)
  1761. }
  1762. }
  1763.  
  1764. if(butIndx == 3 || butIndx == 4){
  1765. const _this = $(sortWhat.sorti[butIndx].el_img)
  1766. press = _this
  1767. //_this.hasClass("headerSortDown") ? _this.removeClass("headerSortDown").addClass("headerSortUp"):_this.removeClass("headerSortUp").addClass("headerSortDown")
  1768. } /*else{
  1769. $(__this).hasClass("headerSortDown") ? $(__this).removeClass("headerSortDown").addClass("headerSortUp"):$(__this).removeClass("headerSortUp").addClass("headerSortDown")
  1770. }*/
  1771.  
  1772. sortWhat.sorti.map(function(currarr, indarr){
  1773. if(indarr !== butIndx){
  1774. currarr.press = false
  1775. //$(currarr.el_img).removeClass("headerSortUp headerSortDown")
  1776.  
  1777. if($(currarr.el_img).is("img")) $(currarr.el_img).css("transform", "scaleY(1)");
  1778. else $(currarr.el_img).find("img").css("transform", "scaleY(1)")
  1779. }
  1780. })
  1781.  
  1782. if($(press).is("img")){
  1783. $(press).css("transform", "scaleY("+(dataClicked?"1":"-1")+")")
  1784. } else {
  1785. $(press).find("img[width^=15]").css("transform", "scaleY("+(dataClicked?"1":"-1")+")")
  1786. }
  1787.  
  1788. sortWhat.sorti[butIndx].press = !sortWhat.sorti[butIndx].press
  1789.  
  1790. if(debug) console.log("Button: ",butIndx,"Value buttons: ",sortWhat.sorti[0].press,sortWhat.sorti[1].press,sortWhat.sorti[2].press,sortWhat.sorti[3].press,sortWhat.sorti[4].press)
  1791. }
  1792.  
  1793. // Эвенты для заголовков
  1794. function setEventHeaderTitle(massiv){
  1795. let titleSort = [],
  1796. titles = $(this).find(".backgr > td").each(function(idxel, el){
  1797.  
  1798. if(idxel == 0) return true
  1799. if(idxel == 4 && el.textContent == "Пиры"){
  1800. let img = $("<img>").attr({"src":"https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/arrow_icon.gif","width":"15"}).css({"position": "relative","top":"3px","cursor": "pointer"}).attr({"title":"Сортировать по Раздающим","id":"_Up"}),
  1801. img_clone = img.clone(false).attr({"title":"Сортировать по Качающим","id":"_Down"})
  1802. $(el).css({"width": "90px"}).append($("<div>").text(" Р",).css({"cursor": "pointer"}).attr({"title":"Сортировать по Раздающим","id":"_Up"}),
  1803. el,img,
  1804. $("<div>").text("К").css({"cursor": "pointer"}).attr({"title":"Сортировать по Качающим","id":"_Down"}),
  1805. el,img_clone
  1806. )
  1807. titleSort.push({
  1808. el_img: $(el).find("div").eq(0),el_img:img,
  1809. index: idxel,
  1810. press: false},
  1811. {
  1812. el_img: $(el).find("div").eq(1),el_img:img_clone,
  1813. index: idxel+1,press: false
  1814. })
  1815. } else {
  1816. let img = $("<img>").attr({"src":"https://raw.githubusercontent.com/AlekPet/Rutor-Preview-Ajax/master/assets/images/arrow_icon.gif","width":"15"}).css({"position": "relative","top": ($(el).children().first().is("img")?"-10px":"3px")})
  1817. $(el).css({"width": "80px", "cursor": "pointer"}).attr("title","Сортировать по \""+($(el).children().first().is("img")?"Добавлено":$(el).text())+"\"").append(img)
  1818. titleSort.push({
  1819. el_img: el,el_img:el,
  1820. index: idxel,
  1821. press: false})
  1822. }
  1823. })
  1824. massiv.sorti = titleSort
  1825. // By date
  1826. titles.eq(1).click(function(){
  1827. correctSortRazdch.call(this,massiv,0, "date",0)
  1828. })
  1829. // By name
  1830. titles.eq(2).click(function(){
  1831. correctSortRazdch.call(this,massiv,1, "name",1)
  1832. })
  1833. // By size
  1834. titles.eq(3).click(function(){
  1835. correctSortRazdch.call(this,massiv,0, "size",2)
  1836. })
  1837. // By Up/Down
  1838. titles.eq(4).find("div, img").each(function(img_indx, el){ // titles.eq(4).find("img")
  1839. $(this).click(function(){
  1840. if(el.id == "_Up"){
  1841. correctSortRazdch.call(el, massiv, 0, "up",3)
  1842. } else {
  1843. correctSortRazdch.call(el, massiv, 0, "down",4)
  1844. }
  1845. })
  1846. })
  1847. }
  1848.  
  1849. function sorting(){
  1850. if(!searchinHost("/torrent/")){
  1851. // Ищим классы для получения данных
  1852. let massivT = [],
  1853. month = ["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],
  1854. razmeronosti = ["kB","MB","GB"]
  1855.  
  1856. $("#index > table").each(function(idx, eltable){
  1857.  
  1858. let objCat = {category:this, name:$(this).prev().text(), razd:[]}
  1859.  
  1860. $(this).find(".gai, .tum").each(function(){
  1861.  
  1862. let colR, colU, size
  1863. if(this.children.length == 5){
  1864. colR = this.children[4].children[0].textContent
  1865. colU = this.children[4].children[2].textContent
  1866. size = this.children[3].textContent
  1867. } else{
  1868. colR = this.children[5].children[0].textContent
  1869. colU = this.children[5].children[2].textContent
  1870. size = this.children[4].textContent
  1871. }
  1872.  
  1873. // Date
  1874. let dateT = this.children[1].textContent
  1875. dateT = dateT.split(/\s+/)
  1876.  
  1877. $.each(month, function(idx,val){
  1878. if(dateT[1] == val.substr(0,3)) dateT[1] = idx
  1879. })
  1880.  
  1881. dateT = new Date(parseInt("20"+dateT[2]), dateT[1], dateT[0], 0,0,0)
  1882.  
  1883. // Sizes
  1884. let complSize
  1885. $.each(razmeronosti, function(idx,val){
  1886. if(size.includes(val)){
  1887. complSize = size.substr(0, size.indexOf(razmeronosti[idx]))*1
  1888. if(idx == 0){
  1889. complSize = complSize *1
  1890. } else if(idx == 1){
  1891. complSize = complSize * 1000
  1892. } else if(idx == 2){
  1893. complSize = complSize *1000000
  1894. }
  1895. } else {
  1896. complSize = parseFloat(size)
  1897. }
  1898. })
  1899.  
  1900. let nameSorti = this.children[2].children[5].textContent
  1901. if(!nameSorti || nameSorti.length == 0) nameSorti = this.children[2].children[0].getAttribute('title');
  1902.  
  1903. objCat.razd.push({es:this, date:dateT, name:nameSorti, size:complSize, up:colR, down:colU})
  1904. })
  1905. massivT.push(objCat)
  1906. setEventHeaderTitle.call(this, massivT[idx])
  1907.  
  1908. })
  1909. if(debug)console.log("Sorting obj:",massivT)
  1910. }
  1911. }
  1912.  
  1913. function AdBlock(){
  1914. if($(".sideblock2").length){
  1915. $(".sideblock2").remove();
  1916. }
  1917.  
  1918. $(['https://code.jquery.com/jquery-3.1.0.min.js','https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js']).each(function(){
  1919. let jquery = document.createElement('script')
  1920. jquery.type = "text/javascript"
  1921. jquery.src = this
  1922. document.head.appendChild(jquery)
  1923. })
  1924.  
  1925. }
  1926.  
  1927. function init(){
  1928. //setTimeout(function(){
  1929. //AdBlock();
  1930. loadStorage();
  1931. makePanel();
  1932. addPoleInfo();
  1933. remakeFav();
  1934. updateFav();
  1935. sorting();
  1936.  
  1937. //if(searchinHost("/top/")) sorting(); // using jquery.tablesorter on site, run only TOP category
  1938. //}, 500);
  1939. }
  1940.  
  1941. // To fix the script on the website:
  1942. // Replace the function 'sotrdgts' (jquery.tablesorter) on the site,
  1943. // because there is an error on the site and the userscript does not work correctly!
  1944. /*document.addEventListener('readystatechange', function(){
  1945. if(document.readyState == 'interactive'){
  1946. $(`<script>function sotrdgts() {
  1947. if($(".sorted tbody td").length) {
  1948. $(".sorted tbody td").each(function() {
  1949. $(this).html("<s>" + appndvl($(this).html()) + "</s>" + $(this).html());
  1950. });
  1951. $(".sorted tbody td[colspan=2]").each(function() {
  1952. $(this).replaceWith('<td>' + $(this).html() + '</td><td></td>');
  1953. });
  1954. $(".sorted").each(function() {
  1955. $(this).tablesorter({
  1956. widgets: ['zebra'],
  1957. headers: {
  1958. 0: { sorter: 'digit' } ,
  1959. 3: { sorter: 'digit' } ,
  1960. 4: { sorter: 'digit' }
  1961. }
  1962. });
  1963. });
  1964. } else {
  1965. setTimeout(function() {sotrdgts();}, 200);
  1966. }
  1967. }</script>`).appendTo(document.body);
  1968.  
  1969. } else if(document.readyState == 'complete'){
  1970. init();
  1971. }
  1972. });*/
  1973.  
  1974. /*window.onload = function(){
  1975.  
  1976. let scripts = [
  1977. 'https://vjs.zencdn.net/7.20.3/video.min.js',
  1978. 'https://cdn.jsdelivr.net/npm/@videojs/http-streaming@2.15.0/dist/videojs-http-streaming.min.js'
  1979. ],
  1980. body = document.querySelector('body')
  1981.  
  1982. for(let s of scripts){
  1983. let script = document.createElement('script')
  1984. script.type = 'text/javascript'
  1985. script.charset = 'utf-8'
  1986. script.src = s
  1987. body.appendChild(script)
  1988. }
  1989. }*/
  1990.  
  1991. init()
  1992.  
  1993. })();