primewire fix

this is an include script meant for internal testing

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @require https://update.greasyfork.org/scripts/8972/136093/primewire%20fix.js

  1. // ==UserScript==
  2. // @name primewire fix
  3. // @namespace primewire fix
  4. // @description this is an include script meant for internal testing
  5. // @author drhouse
  6. // @include https://www.primewire.ag/*
  7. // @version 1.0.2
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. (function ($) {
  12.  
  13.  
  14. var lobject = $('.logged_username a').get()
  15. if (!lobject) {
  16. $('.warning_message').append($('<div>').css({
  17. color: 'red'
  18. }).setText("You must be logged in for this userscript to work").get())
  19. return
  20. }
  21. var queryString = (function (s) {
  22. var q = s.split('?')[1]
  23. var qs = {}
  24. if (q) {
  25. q.split('&').forEach(function (o) {
  26. var t = o.split('=');
  27. qs[unescape(t[0])] = unescape(t[1])
  28. })
  29. }
  30. return qs
  31. })(document.URL)
  32. var groups = __getValue('groups');
  33.  
  34. // $('.header_search').swap($('.nav_tabs'))
  35. var uname = lobject.innerHTML;
  36. var DEBUG = false;
  37. var __groups = ['fav','towatch','watched'];
  38. if (!('watched' in groups) ) {
  39. set_up();
  40. }
  41. function set_up() {
  42.  
  43. $('<div>').attr('id','blanket').css({
  44. 'position':'absolute',
  45. 'backgroundColor':'#666',
  46. 'opacity':'0.5',
  47. 'left':'0px',
  48. 'top':'0px',
  49. 'width':'100%',
  50. 'height':'100%'
  51. }).appendTo(document.body)
  52. $('<div>').attr('id','fs_info_box').css({
  53. 'backgroundColor':'white',
  54. 'width':'600px',
  55. 'border':'1px solid black',
  56. 'borderRadius': '20px',
  57. 'margin':'auto',
  58. 'height':'400px',
  59. 'position':'absolute',
  60. 'top':'25%',
  61. 'left':'25%',
  62. 'padding':'5px',
  63. 'fontSize':'14px'
  64. }).setText('1channel.ch Fix needs to set up. We need to get the list of Watched To Watch and Favorite groups so when browsing you can see which are in what group.')
  65. .append($('<ul>').css({'padding':'50px'})
  66. .append($('<li>').attr('id','fav').setText('Favorites').append($('<b>')).append($('<progress>')))
  67. .append($('<li>').attr('id','watched').setText('Watched').append($('<b>')).append($('<progress>')))
  68. .append($('<li>').attr('id','towatch').setText('To Watch').append($('<b>')).append($('<progress>')))
  69. )
  70. .appendTo(document.body)
  71. $('#fs_info_box ul li').css({'opacity':'1'})
  72. $('#fs_info_box progress').attr('value','0').attr('max','100').css({'display':'block'});
  73. var _groups = ['fav','watched','towatch'];
  74. $(document.body).css({
  75. 'overflowY':'hidden'
  76. })
  77. get_page();
  78. function get_page(page,n) {
  79. var page = page||_groups.shift()
  80. if (page) {
  81. groups[page] = groups[page]||[]
  82. var n = n||1
  83. var o = $('#'+page)
  84. _get('/profile.php?user='+uname+'&'+page+'=&page='+n,function(r) {
  85. var s = r.responseText;
  86. var tot = s.match(/\(( [1-9]\d* )\)<\/strong>/i) && RegExp.$1;
  87.  
  88. if (tot) {
  89. var l_page = s.match(/&page=(\d+)"> >>/) && RegExp.$1
  90.  
  91. var done = !l_page
  92. o.children('b',1).clear().setText(tot + " total items page: "+n+'/'+(l_page||n));
  93. var reg = /class="index_item"> <a href="\/(?:tv|watch)-(\d+)/g,t
  94. while ((t = reg.exec(s)) !== null) {
  95. // console.log("Group: '%s' Item: '%s'",page,t[1])
  96. groups[page].push(t[1]);
  97. }
  98. o.children('progress',1).attr('max',l_page||n).attr('value',n)
  99.  
  100. if (done) {
  101. get_page()
  102. }
  103. else {
  104. get_page(page,++n)
  105. }
  106. }
  107. else {
  108. console.log(s)
  109. o.children('b',1).clear().setText(' No Items');
  110. o.children('progress',1).attr('value',100);
  111. get_page()
  112. }
  113. });
  114. }
  115. else {
  116. $('#fs_info_box').append($('<h1>').setText('DONE'));
  117. __setValue('groups',groups);
  118. setTimeout(function() {
  119. $('#fs_info_box,#blanket').fadeOut(1,function() {
  120. this.remove()
  121. $(document.body).css({'overflow-y':'auto'});
  122. });
  123. },1000)
  124. }
  125. }
  126. }
  127. GM_addStyle('x-btn-icon { \
  128. width: 11px;\
  129. height: 13px;\
  130. }\
  131. .x-btn:active,.options_menu + .x-btn { \
  132. border-color: #999 !important;\
  133. background: #DDD !important;\
  134. background-image: -moz-linear-gradient(top,#cccccc,#ffffff) !important;\
  135. background-image: -webkit-gradient(linear,left top,left bottom,from(#cccccc),to(#ffffff)) !important;\
  136. filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#cccccc,endColorStr=#ffffff) !important;\
  137. opacity:1 !important\
  138. }\
  139. .x-btn:hover { \
  140. border-color: #999;\
  141. background: #F3F3F3;\
  142. background-image: -moz-linear-gradient(top,#ffffff,#ebebeb);\
  143. background-image: -webkit-gradient(linear,left top,left bottom,from(#ffffff),to(#ebebeb));\
  144. filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#ffffff,endColorStr=#ebebeb);\
  145. outline: 0;\
  146. -moz-box-shadow: 0 0 3px #999;\
  147. -webkit-box-shadow: 0 0 3px #999;\
  148. box-shadow: 0 0 3px #999;\
  149. }\
  150. .x-btn,.options_menu {\
  151. padding: 0 .5em;\
  152. height: 2.0833em;\
  153. border: 1px solid #CCC;\
  154. color: black;\
  155. background: #F6F6F6;\
  156. background-image: -moz-linear-gradient(top,#ffffff,#efefef);\
  157. background-image: -webkit-gradient(linear,left top,left bottom,from(#ffffff),to(#efefef));\
  158. filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#ffffff,endColorStr=#efefef);\
  159. -moz-border-radius: 3px;\
  160. -webkit-border-radius: 3px;\
  161. border-radius: 3px;\
  162. white-space: nowrap;\
  163. vertical-align: middle;\
  164. cursor: pointer;\
  165. overflow: visible;\
  166. opacity:0;\
  167. }\
  168. .episode_prev_next button {\
  169. padding:0 .5em;\
  170. -moz-border-radius: 3px;\
  171. -webkit-border-radius: 3px;\
  172. border-radius: 3px;\
  173. }\
  174. .index_item:hover .x-btn,.featured_movie_item:hover .x-btn,.item_similar:hover .x-btn {\
  175. opacity:1 !important;\
  176. }\
  177. .index_item {\
  178. max-height:305px;\
  179. min-height:305px;\
  180. }\
  181. .index_item img { \
  182. display:block !important;\
  183. width:150px;\
  184. min-height:222px\
  185. }\
  186. .index_container { \
  187. \
  188. }\
  189. .options_menu { \
  190. position: absolute;\
  191. height: auto !important;\
  192. width: auto !important;\
  193. opacity:1 !important;\
  194. top: 2.2em;\
  195. list-style:none;\
  196. width:100px;\
  197. }\
  198. \
  199. .options_menu li:not(.label) { \
  200. font-size: 12px;\
  201. padding-left:5px;\
  202. \
  203. }\
  204. .options_menu li:not(.label):hover {\
  205. background-color: #EFFFEF;\
  206. color:black;\
  207. }\
  208. .options_menu li {\
  209. min-width:100px;\
  210. }\
  211. .options_menu li.label { \
  212. font-size: 12px;\
  213. color: white;\
  214. padding:0px;\
  215. background-color: #3c3c3c;\
  216. height:10px\
  217. line-height:20px;\
  218. font-weight:bold;\
  219. border:1px solid black;\
  220. }\
  221. .loader {\
  222. opacity: .5;\
  223. position:absolute;\
  224. top:0;\
  225. left:5;\
  226. background-color:#EFEFEF;\
  227. }\
  228. .hide {\
  229. display:none !important;\
  230. }\
  231. .comments_box_vote { position: relative; }\
  232. #autoc {\
  233. position:absolute;\
  234. padding:3px;\
  235. border:2px solid black;\
  236. padding:5px;\
  237. background-color: #fff; \
  238. border: 2px solid #666;\
  239. border-top:none;\
  240. -webkit-border-radius: 0px 30px 30px; \
  241. -moz-border-radius: 0px 30px 30px; \
  242. border-radius: 0px 30px 30px; \
  243. -webkit-box-shadow: 2px 15px 15px #888; \
  244. -moz-box-shadow: 2px 15px 15px #888; \
  245. box-shadow: 2px 15px 15px #888;\
  246. width: 320px;\
  247. z-index:200;\
  248. display:none;\
  249. }\
  250. #autoc li {\
  251. \
  252. list-style: none;\
  253. background-color: white;\
  254. border: 1px solid #EEE;\
  255. color: black;\
  256. padding:2px;\
  257. }\
  258. #autoc li:first-child {\
  259. border-top-right-radius: 30px;\
  260. }\
  261. \
  262. #search_term:focus ~ ul {\
  263. display: block !important;\
  264. }\
  265. #autoc:hover {\
  266. display: block !important;\
  267. }\
  268. #autoc li:last-child {\
  269. border-bottom-right-radius: 30px;\
  270. border-bottom-left-radius: 30px;\
  271. }\
  272. #autoc li:hover,#autoc li.current {\
  273. background-color:#E8F0F4;\
  274. }\
  275. ');
  276. var waiting_image = "data:image/gif;base64,R0lGODlhgACAAKIEAP///93d3bu7u5mZmf///wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBQAEACwAAAAAgACAAAAD/0i63P4wykmrvTjrzbv/oAaMQGieaEaSaeu66/rOdBezda5P97j/wEWvFCzmhsbkDKlsEgLQwIfZGVgHTk006qFurtfsZbu19argsJhC5nK8mbR6LWm7Reev3Eqf2O8YcBZ7c30Qf1J4N3p7hmx/ijEahFiOfpAqeRiUlo92mYubhJ2enxeCEpSVpHWYFqgRnKyXrhSwD6qzpWSnmhSyurRtr76po8G7ZRW3DcDIraY8xRDOzxGIiRLMCrnWyYAQ2wTV3oeI0qGx5OUP5+g4xo10AvQCIe7a8OryH2Af9fVA4AuxLk6aDgATfqgF4hgafhkSSuzAsB9EgwUpSNzIYf9YCjkcVBXCsJHjBmUt/DESibDkRHbURI7U4NIkTG4yZ3Ko+bJcTp0eeCr09pOPC6EAkRVdNQNpQFJLfzil1ylqkKmOijZBmlXmGp5dMyapGfbivJ6GzDpKChXozbdw48qdS7eu3bt48+rdy7cv36XdfAJ2yGBw4GeGqyU+LIQIARmQI0uadmGxM8uEGysYMpmIDxaRH2JWiXM0aQY+HnsGzXpzCXG/TJ+WfVqzatdnUn9+HTokbaMLfodbvaj3btWtU29G7bgZbVymI0jmjXy67uLNszd3Ptqv9+/gw4sfT768+fPo06unUTutWzpqxcTPwli+WCMs3d//kbPsfvb/P/lXXw5WCTjgCwVakiCCWgWz4AkP6hKhBxNK2GBDF95U4SAB0pUhRvlN8h6FI+4TIoj/QdcehitW0N9K88UGEoQxTnCiKDXKeBCNM4q2I4xM+ZYjjj36GKSIwJ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EIAQgAAA/VIBNz+8KlJq72Yxs1d/uDVjVxogmQqnaylvkArT7A63/V47/m2/8CgcEgsGo/IpHLJbDqf0Kh0Sj0FroGqDMvVmrjgrDcTBo8v5fCZki6vCW33Oq4+0832O/at3+f7fICBdzsChgJGeoWHhkV0P4yMRG1BkYeOeECWl5hXQ5uNIAOjA1KgiKKko1CnqBmqqk+nIbCkTq20taVNs7m1vKAnurtLvb6wTMbHsUq4wrrFwSzDzcrLtknW16tI2tvERt6pv0fi48jh5h/U6Zs77EXSN/BE8jP09ZFA+PmhP/xvJgAMSGBgQINvEK5ReIZhQ3QEMTBLAAAh+QQFBQAEACwCAB8AMABXAAAD50i6DA4syklre87qTbHn4OaNYSmNqKmiqVqyrcvBsazRpH3jmC7yD98OCBF2iEXjBKmsAJsWHDQKmw571l8my+16v+CweEwum8+hgHrNbrvbtrd8znbR73MVfg838f8BeoB7doN0cYZvaIuMjY6PkJGSk2gClgJml5pjmp2YYJ6dX6GeXaShWaeoVqqlU62ir7CXqbOWrLafsrNctjIDwAMWvC7BwRWtNsbGFKc+y8fNsTrQ0dK3QtXAYtrCYd3eYN3c49/a5NVj5eLn5u3s6e7x8NDo9fbL+Mzy9/T5+tvUzdN3Zp+GBAAh+QQJBQAEACwCAAoAMABXAAAD60i63P4LSACrvW1OzLvSmidW4DaeTGmip7qyokvBrUuP8o3beifPPUwuKBwSLcYjiaeEJJuOJzQinRKq0581yoQEvoEelgAG67Dl9K3LSLth7IV7zipV5nRUyILPT/t+UIBvf4NlW4aHVolmhYyIj5CDW3KAlJV4l22EmptfnaChoqOkpaanqKk6Aqytrq+wrzCxtLWuKLa5tSe6vbIjvsECvMK9uMW2s8ixqs3Oz9DR0tPUzwPXA6PY26Db3tmX396U4t9W5eJQ6OlN6+ZK7uPw8djq9Nft9+Dz9FP3W/0ArtOELtQ7UdysJAAAOw%3D%3D"
  277. var host = window.location.host;
  278.  
  279. var show_menu = false
  280.  
  281. function kill_menu(n) {
  282. setTimeout(function () {
  283. if (show_menu) return show_menu = false
  284. $('.options_menu').remove()
  285. }, 10);
  286. }
  287. $('body').listen('click', kill_menu);
  288.  
  289. $('.search_container').css({
  290. 'position': 'relative'
  291. }).append($('<ul>').listen('click', function (e) {
  292. $(e.currentTarget).clear()
  293. }).attr('id', 'autoc'));
  294. $('#search_term').listen(['keyup', 'focus'], function (e) {
  295. if ([40, 38].indexOf(e.keyCode) > -1) return
  296. clearTimeout(_alist_t);
  297. if (this.value.trim().length > 2) _alist_t = setTimeout(Alist, 50);
  298. if (this.value.trim() === "") $('#autoc').clear();
  299.  
  300. }).listen('keydown', function (e) {
  301. switch (e.keyCode) {
  302. case 40:
  303. $('#autoc li.current').removeClass('current').nextSibling(1).addClass('current')
  304. $('#search_term').get().value = $($('#autoc li.current').get() || $('#autoc li:first-child').get()).addClass('current').get().textContent
  305. break;
  306. case 38:
  307. $('#autoc li.current').removeClass('current').previousSibling(1).addClass('current')
  308. $('#search_term').get().value = $($('#autoc li.current,#autoc li:last-child').get()).addClass('current').get().textContent
  309. break;
  310. }
  311. }).listen('click', function () {
  312.  
  313. }).listen('keydown', function (e) {
  314. clearTimeout(_alist_t);
  315. });
  316. var _alist, _alist_t, _alist_o = {};
  317.  
  318. function Alist() {
  319. try {
  320. _alist.abort()
  321. }
  322. catch (err) {}
  323. var value = $('#search_term').addClass('ac_loading').get().value.trim();
  324. if (_alist_o[value.toLowerCase()]) return Ac(_alist_o[value.toLowerCase()]);
  325. $('#search_term').addClass('ac_loading')
  326. _alist = new XMLHttpRequest();
  327. _alist.open('GET', '/_get_active_movies.php?all&limit=10&q=' + encodeURIComponent(value), true);
  328. _alist.onreadystatechange = function (e) {
  329. if (_alist.readyState === 4) {
  330. if (_alist.status === 200) {
  331. $('#search_term').removeClass('ac_loading')
  332. Ac((_alist_o[value.toLowerCase()] = _alist.responseText.trim().split(/\n/)))
  333. }
  334. }
  335. }
  336. _alist.send()
  337. }
  338.  
  339. function Ac(l) {
  340. var ac = $('#autoc').clear()
  341. l.forEach(function (o) {
  342. ac.append($('<li>').setText(o).listen('click', function (e) {
  343. e.preventDefault()
  344. $('#search_term').get().value = this.textContent;
  345. }))
  346. });
  347. }
  348. function XmlhttpRequest(obj) {
  349. if (obj.url.indexOf("http://") === 0 && obj.url.indexOf('http://'+host) === -1) {
  350. GM_xmlhttpRequest(obj)
  351. }
  352. else {
  353. var xhr = new XMLHttpRequest();
  354. xhr.open(obj.method, obj.url, true);
  355. xhr.onreadystatechange = function (e) {
  356. if (xhr.readyState === 4) {
  357. obj.onload(xhr)
  358. }
  359. }
  360. xhr.send(obj.data||null)
  361. }
  362.  
  363. }
  364. function _get(url, cb, postData, headers) {
  365. XmlhttpRequest({
  366. method: postData ? 'POST' : 'GET',
  367. url: url,
  368. data: postData,
  369. headers: headers || null,
  370. onload: function (r) {
  371. cb(r);
  372. }
  373. });
  374. }
  375.  
  376. function do_watched(what, action, id, page) {
  377.  
  378. var url = "/addto" + (page || "watched") + ".php?whattodo=" + what + "&action=" + action + "&id=" + id;
  379. do_action.call(this, url)
  380.  
  381. }
  382.  
  383. function do_action(url, cb) {
  384. if (!$(this).children('.loader').length) {
  385. $(this).append($('<div>').attr('class', 'loader hide').append($('<img>').attr('src', waiting_image).get()).get())
  386. }
  387. $($(this).children('.loader')[0]).show()
  388. _get(url, function (r) {
  389. var ok = get_ok(r.responseText);
  390. if (ok) {
  391. var m = url.split('?')
  392. var t = m[0].match(/addto(.*?)s?\.php/i) && RegExp.$1,q={}
  393. m[1].split("&").forEach(function(i) {
  394. var v = i.split('=');
  395. q[v[0]] = v[1];
  396. })
  397. var g = q['action'] || t;
  398. console.log(url,g,q);
  399. if (q['whattodo'] == 'delete') {
  400. groups[g].splice(groups[g].indexOf(q['id']),1);
  401. }
  402. else if(q['whattodo'] == 'add') {
  403. if (g === 'watched' && (m = groups['towatch'].indexOf(q['id'])) > -1) {
  404. groups['towatch'].splice(m,1);
  405. }
  406. groups[g].indexOf(groups[g]) === -1 && groups[g].push(q['id'])
  407. }
  408. __setValue('groups',groups);
  409. }
  410. $($(this).children('.loader')[0]).hide()
  411. $(this).append($('<div>').css({
  412. 'backgroundColor': ok?'#EFFFEF':'red',
  413. "width": "100%",
  414. "position": "absolute",
  415. "top": "40%",
  416. "left": "0px"
  417. }).setText(ok || "An Error Occurred").get())
  418. if (cb) cb(ok)
  419. }.bind(this), null, {
  420. "Referer": document.URL
  421. });
  422. }
  423.  
  424. function _menu(obj) {
  425. $('.options_menu').remove()
  426. var ul = $('<ul>').attr('class', 'options_menu')
  427. for (var i in obj) {
  428. if (/^wait/.test(i)) {
  429. var li = $('<li>').attr('class', 'wait').setText(i)
  430. ul.append(li)
  431. obj[i].call(null, li)
  432. }
  433. else {
  434. ul.append($('<li>').setText(i).attr('class', obj[i] ? '' : 'label').listen('click', typeof obj[i] == 'function' && obj[i]).get())
  435. }
  436.  
  437. }
  438. return ul;
  439. }
  440.  
  441. function build_menu(id) {
  442. // .bind(a)
  443. // look for playlists
  444. return _menu({
  445. "add To:": null,
  446. "To Watch": function () {
  447. do_watched.call(this, 'add', 'towatch', id)
  448. }.bind(this),
  449. "Watched": function () {
  450. do_watched.call(this, 'add', 'watched', id)
  451. }.bind(this),
  452. "Favorite": function () {
  453. do_watched.call(this, 'add', '', id, 'favs')
  454. }.bind(this),
  455. "wait1": function (xli) {
  456. if ('tv' in queryString || queryString['search_section'] == "2") {
  457. xli.addClass('label').clear().setText('Go To:')
  458. xli.insertAfter($('<li>').setText('Last Episode').listen('click', function (e) {
  459. show_menu = true
  460. $(e.target).clear().setText("Getting Last Page")
  461. _get("/watch-" + id, function (r) {
  462. var s = r.responseText,
  463. t = /href="(.*?)"/g
  464. if ((lI = s.lastIndexOf('tv_episode_item"> <a href="')) > -1) {
  465. t.lastIndex = lI
  466. var m = t.exec(s)
  467.  
  468. window.location.assign("http://" + host + m[1])
  469. }
  470. else alert('No Episodes Found') && kill_menu()
  471. }.bind(this))
  472. }.bind(this)).get())
  473.  
  474.  
  475. }
  476. else {
  477. xli.remove()
  478. }
  479. }.bind(this),
  480. "Playlists": null,
  481. "wait2": function (xli) {
  482. xli.clear()
  483. xli.setText("waiting for playlists")
  484. var ul = xli.get().parentNode;
  485. var li = xli.get()
  486. _get('/playlists/' + uname, function (r) {
  487. var t = r.responseText;
  488. var reg = /"\/playlists\.php\?id=(\d+?)">([^<]+)<\/a>/g,
  489. m
  490. var has = false;
  491. while ((m = reg.exec(t)) !== null) {
  492. has = true
  493. var pid = m[1];
  494. var pname = m[2];
  495. ul.insertBefore($('<li>').setText(pname).listen('click', function () {
  496.  
  497. do_action.call(ul.parentNode, 'http://' + host + '/playlists.php?user=' + uname + '&edit=' + pid + '&plistitemid=' + id + '&whattodo=add_existing')
  498.  
  499. }).get(), li)
  500. }
  501. if (!has) {
  502. ul.insertBefore($('<li>').setText('No Playlists').get(), li)
  503. }
  504. xli.clear()
  505. });
  506. /*
  507. _get('http://' + host + '/playlists.php?create', function (r) {
  508. var s = r.responseText;
  509. var n = s.match(/<input name="play_title".*?value"(.*?)"/)
  510. xli.clear().setText((n && n[1]) || "Create New Playlist").listen('click', function (e) {
  511. if (n) {
  512. do_action.call(ul.parentNode, 'http://www.1channel.ch/playlists.php?plistitemid=' + id + '&whattodo=add')
  513. } else {
  514. show_menu = true
  515. e.stopPropagation()
  516. $(this).clear().append($('<input>').attr('placeholder', 'Type PlaylistName').listen('keypress', function (e) {
  517. if (e.keyCode == 13) {
  518. //do_action.call(ul.parentNode, 'http://' + host + '/playlists.php?user=' + uname + '&edit=' + pid + '&plistitemid=' + id + '&whattodo=add_existing')
  519. _get('http://' + host + '/playlists.php?create', function (r) {
  520. if (r.responseText.match(/<input name="play_title".*?value"(.*?)"/)) {
  521. $(this).clear().setText(RegExp.$1);
  522. do_action.call(ul.parentNode, 'http://www.1channel.ch/playlists.php?plistitemid=' + id + '&whattodo=add', function () {
  523. show_menu = false
  524. kill_menu();
  525. })
  526. } else {
  527. alert('no');
  528. }
  529. }.bind(this), "play_title=" + encodeURIComponent(this.value) + "&type=1&play_submit=Search");
  530. }
  531. }))
  532.  
  533. }
  534. })
  535. });
  536. */
  537. }.bind(this)
  538.  
  539.  
  540. });
  541. }
  542.  
  543.  
  544. function __getValue(key) {
  545. var s = GM_getValue(key);
  546. return (s && JSON.parse(s)) || {}
  547. }
  548.  
  549. function __setValue(key, value) {
  550. setTimeout(function() {
  551. GM_setValue(key, JSON.stringify(value));
  552. },0);
  553. }
  554.  
  555. function get_ok(txt) {
  556. return txt.match(/<div class='ok_message'>(.*?)<\/div>/i) && RegExp.$1
  557.  
  558. }
  559. __groups.forEach(function(o) { if (o === 'fav') return
  560. var lists = groups[o].map(function(oo) {
  561. return 'a[href*="-'+oo+'-"] img';
  562. });
  563. var rib = (o === 'towatch' && 'to_watch') || o
  564. $(lists.join(',')).i(function(o) {
  565. var tt = $(o)
  566. var im = tt.attr('src')
  567. if (im.indexOf('/images/ribbon') === -1) {
  568. tt.attr('height',tt.get().offsetHeight);
  569. tt.attr('src','/images/ribbon_'+rib+'.png').css({'background':'url('+im+')'})
  570. }
  571. });
  572. });
  573.  
  574. $('a[href*="commentvote="]').listen('click', function (e) {
  575. e.preventDefault();
  576. do_action.call(this.parentNode.parentNode, this.href);
  577.  
  578.  
  579. });
  580. $('.favs_deleted a').listen('click', function (e) {
  581. e.preventDefault()
  582. do_action.call($(this).parent(1).parent(), this.href, function (ok, txt) {
  583. if (ok) {
  584. var t = $(this).parent(1).parent(1)
  585. var opts = {
  586. prop: 'opacity',
  587. from: 1,
  588. to: 0,
  589. time: .1,
  590. delta: function (p) {
  591. return 1 - Math.sin(Math.acos(p))
  592. }
  593. }
  594. t.animate(opts).__registerListener('animationEnd', function () {
  595. this.remove()
  596. })
  597. }
  598. else {
  599. alert("Could Not Complete Action");
  600. }
  601. }.bind(this))
  602.  
  603.  
  604. });
  605. $('.index_item,.featured_movie_item,.item_similar a').i(function (o) {
  606.  
  607. $(o).css({
  608. 'position': 'relative'
  609. }).append($('<button>').attr('class', 'x-btn').setText("+").css({
  610. "position": "absolute",
  611. "left": "0px",
  612. "top": "0px",
  613. "textSize": "2em"
  614. }).listen('click', function (e) {
  615. show_menu = true
  616. if (this.parentNode.tagName.toLowerCase() == 'a') {
  617. e.preventDefault()
  618. }
  619.  
  620. var id = (this.parentNode.href || this.parentNode.querySelector('a').href).match(/(?:tv|watch)-(\d+)/)[1];
  621. this.parentNode.insertBefore(build_menu.call(o, id).get(), this)
  622.  
  623. }).get());
  624.  
  625. });
  626. $('.index_item + .clearer').remove();
  627. $('.pagination').css({
  628. 'clear': 'both'
  629. })
  630.  
  631. if (document.URL.match(/\/tv-(\d+).*?\/season-(\d+)-episode-(\d+)/i)) {
  632.  
  633. var id = RegExp.$1,
  634. s = [Number(RegExp.$2), Number(RegExp.$3)].join("x");
  635. var tv = __getValue('watched');
  636. $('.episode_prev_next').append($('<button>').setText('Watched').listen('click', function () {
  637. var tv = __getValue('watched');
  638. if (!tv[id]) {
  639. tv[id] = {}
  640. }
  641.  
  642. tv[id][s] = !tv[id][s];
  643. __setValue('watched', tv);
  644. this.style.backgroundColor = (tv[id] && tv[id][s]) ? "#EFFFEF" : "#FFF"
  645. }).css({
  646. backgroundColor: (tv[id] && tv[id][s]) ? "#EFFFEF" : "#FFF"
  647. }).get())
  648.  
  649.  
  650. }
  651. else if ($('.movie_navigation a').get() && $('.movie_navigation a').get().href.match(/\/tv-(\d+)/i)) {
  652. var id = RegExp.$1
  653. var tv = __getValue("watched");
  654.  
  655. $('a[href*="/season-"]').i(function (o) {
  656. if (o.href.match(/\/tv-.*?\/season-(\d+)-episode-(\d+)/i)) {
  657. var s = [Number(RegExp.$1), Number(RegExp.$2)].join("x")
  658. if (tv[id][s]) {
  659. o.parentNode.style.backgroundColor = "#EFFFEF !important"
  660. }
  661. }
  662. });
  663. }
  664.  
  665. })((function () {
  666. var __matches = (function () {
  667. var dE = document.documentElement
  668. return dE && dE.nodeType && (dE.matchesSelector || dE.webkitMatchesSelector || (dE.mozMatchesSelector &&
  669. function (sel) {
  670. return this.mozMatchesSelector(sel)
  671. }))
  672. })();
  673. var fs = function (m, el) { return new fs.fn(m,el) }
  674. fs.fn = function(m,el) {
  675. m = m || '';
  676. this.obj = []
  677. if (typeof (m) == 'object' && m.nodeType) {
  678. this.obj.push(m)
  679. }
  680. else if (m.match(/^<([^>]+)>$/)) {
  681. this.obj.push(document.createElement(RegExp.$1))
  682. }
  683. else {
  684. this.obj = Array.prototype.slice.call(m == '' ? [] : (el || document).querySelectorAll(m) || [], 0)
  685. }
  686. return this
  687. }
  688. fs.Extend = function (o) {
  689. for (var i in o) {
  690. fs.fn.prototype[i] = o[i];
  691. }
  692. }
  693. fs.isArray = function (o) {
  694. return typeof o === 'object' && o instanceof Array
  695. }
  696. fs.animate = function (opts) {
  697.  
  698. var start = new Date
  699. var id = setInterval(function () {
  700. var timePassed = new Date - start
  701. var progress = timePassed / opts.duration
  702.  
  703. if (progress > 1) progress = 1
  704.  
  705. var delta = opts.delta(progress)
  706. opts.step(delta)
  707.  
  708. if (progress == 1) {
  709. clearInterval(id)
  710. if (opts.onEnd) {
  711. opts.onEnd()
  712. }
  713. }
  714. }, opts.delay || 10)
  715.  
  716. }
  717. fs.Animate = {
  718. linear: function (p) {
  719. return p
  720. },
  721. circ: function (progress) {
  722. return 1 - Math.sin(Math.acos(progress))
  723. }
  724. }
  725. fs.isObject = function (o) {
  726. return typeof o.__isFSObject === 'function' && o.__isFSObject();
  727. }
  728. fs.fn.prototype = {
  729. toString: function() {
  730. return this.obj.toString()
  731. },
  732. matches: function (sel) {
  733. if (__matches) return __matches.apply(this.get(), [sel])
  734. },
  735. __isFSObject: function () {
  736. return this instanceof fs.fn
  737. },
  738. append: function (e) {
  739. e = fs.isObject(e) ? e.get() : e;
  740. this.get().appendChild(e);
  741. return this
  742. },
  743. insertBefore: function (e) {
  744. this.parent().insertBefore(fs.isObject(e) ? e.get() : e, this.get());
  745. },
  746. insertAfter: function (e) {
  747. this.parent().insertBefore(fs.isObject(e) ? e.get() : e, this.get().nextSibling)
  748. },
  749. loaded: function (cb) {
  750. this.listen('DOMContentLoaded', cb);
  751. },
  752. clear: function () {
  753. this.i(function (o) {
  754. while (o.firstChild) {
  755. o.removeChild(o.firstChild)
  756. }
  757. });
  758. return this
  759. },
  760. get: function () {
  761. return this.obj[0];
  762. },
  763. appendTo: function (e) {
  764. if (typeof e === 'string') {
  765. e = $(e).get()
  766. }
  767. else if (fs.isObject(e)) {
  768. e = e.get()
  769. }
  770. e.appendChild(this.get());
  771.  
  772. },
  773.  
  774. children: function (sel,n) {
  775. var sel = sel || '*',
  776. cn = this.get().childNodes,
  777. length = cn.length,
  778. m = []
  779. for (var i = 0; i < length; i++) {
  780. if (cn[i].nodeType === 1 && fs(cn[i]).matches(sel)) m.push(cn[i])
  781. }
  782. if (n) { var x = fs('');x.obj = m;return x }
  783. return m;
  784. },
  785. listen: function (e, cb, cBool) {
  786. if (!fs.isArray(e)) {
  787. e = [e]
  788. }
  789. this.i(function (o) {
  790. e.forEach(function (ee) {
  791. o.addEventListener(ee, function (e) {
  792. cb.call(e.target || e.srcElement, e)
  793. }, cBool || false)
  794. })
  795. });
  796. return this
  797. },
  798. i: function (cb) {
  799. for (var i = 0; i < this.obj.length; i++) {
  800. cb(this.obj[i]);
  801. }
  802. return this;
  803. },
  804. nextSibling: function (f) {
  805. var ns = this.get();
  806. while (ns && (ns = ns.nextSibling) && ns.nodeType != 1) {}
  807. return f ? fs(ns) : ns
  808. },
  809. previousSibling: function (f) {
  810. var ps = this.get();
  811. while (ps && (ps = ps.previousSibling) && ps.nodeType != 1) {}
  812. return f ? fs(ps) : ps
  813. },
  814. parent: function (n) {
  815. var p = this.get().parentNode
  816. return n ? fs(p) : p
  817. },
  818. parents: function (until) {
  819. var m = fs('');
  820. m.obj = []
  821. var o = this.get();
  822. var p
  823. while ((o = o.parentNode) && ((until && !fs(o).matches(until)) || !until)) m.obj.push(o);
  824.  
  825. return m;
  826. },
  827. attr: function (a, s) {
  828. if (s == null) {
  829. return this.get().getAttribute(a)
  830. }
  831. else {
  832. this.i(function (o) {
  833. o.setAttribute(a, s)
  834. });
  835. }
  836. return this;
  837. },
  838. setText: function (t) {
  839. this.i(function (o) {
  840. o.appendChild(document.createTextNode(t));
  841. });
  842. return this
  843. },
  844. toggle: function (cn, bool) {
  845. this.i(function (o) {
  846. if (typeof (bool) === "boolean") {
  847. if (bool) o.classList.add(cn)
  848. else {
  849. o.classList.remove(cn)
  850. }
  851. }
  852. else {
  853. o.classList.toggle(cn || "hide")
  854. }
  855. });
  856. return this
  857. },
  858. addClass: function (cn) {
  859. this.i(function (o) {
  860. o.classList.add(cn)
  861. });
  862. return this
  863. },
  864. removeClass: function (cn) {
  865. this.i(function (o) {
  866. o.classList.remove(cn)
  867. });
  868. return this
  869. },
  870. __listener: {},
  871. __registerListener: function (evt, cb) {
  872. this.__listener[evt] = this.__listener[evt] || [];
  873. this.__listener[evt].push(cb);
  874. },
  875. __fireListener: function (evt, cb) {
  876. if (this.__listener[evt]) {
  877. this.__listener[evt].forEach(function (o) {
  878. o.call(this)
  879. }, this);
  880. }
  881. },
  882. animate: function (aopts) {
  883. var a = aopts.to - aopts.from;
  884.  
  885. fs.animate({
  886. delay: 10,
  887. duration: (aopts.duration || 1) * 1000,
  888. // 1 sec by default
  889. delta: aopts.delta || fs.Animate.linear,
  890. step: function (delta) {
  891. var p = aopts.from + (a * delta) + (aopts.unit || '');
  892. var o = new Object();
  893. o[aopts.prop] = p;
  894. this.css(o)
  895. }.bind(this),
  896. onEnd: function () {
  897. this.__fireListener('animationEnd');
  898. }.bind(this)
  899. });
  900. return this
  901. },
  902. fadeOut: function (time, cb) {
  903. if (cb) {
  904. this.__registerListener('animationEnd', cb)
  905. }
  906. this.animate({
  907. prop: 'opacity',
  908. duration: time,
  909. from: 1,
  910. to: 0
  911. });
  912. },
  913. remove: function () {
  914. this.i(function (o) {
  915. o.parentNode.removeChild(o);
  916. });
  917. },
  918. hide: function () {
  919. this.addClass('hide');
  920. },
  921. show: function () {
  922. this.removeClass('hide');
  923. },
  924. is: function (sel) {
  925. this.obj = this.obj.filter(function (o) {
  926. return fs(o).matches(sel);
  927. });
  928. return this
  929. },
  930. computed: function (attr) {
  931. return document.defaultView.getComputedStyle(this.get(), null).getPropertyValue(attr);
  932. },
  933. __getWH: function (s) {
  934. var c = parseFloat(this.computed('width'));
  935. var opts = ['margin-left', 'margin-right', 'border-left-width', 'border-right-width'];
  936. for (var i = 0, length = opts.length; i < length; ++i) {
  937. c -= parseFloat(this.computed(opts[i]));
  938. }
  939. return c;
  940. },
  941. width: function (n) {
  942. if (n != null) {
  943. this.css({
  944. width: parseFloat(n) + "px !important"
  945. });
  946. }
  947. else {
  948. return this.__getWH('w');
  949. }
  950. },
  951. swap: function (el) {
  952. var o = (el instanceof HTMLElement ? $(el) : el)
  953. var c = o.clone()
  954. var p = this.clone();
  955. o.replace(p);
  956. this.replace(c)
  957. return this
  958.  
  959. },
  960. replace: function (el) {
  961. var o = (fs.isObject(el) ? el.get() : el)
  962. this.parent().replaceChild(o, this.get())
  963. },
  964. clone: function () {
  965. return this.get() && this.get().cloneNode(true)
  966. },
  967. css: function (s) {
  968. this.i(function (o) {
  969. for (var i in s) {
  970. try {
  971. o.style[i] = s[i]
  972. }
  973. catch (err) {}
  974. }
  975. });
  976. return this
  977. },
  978. count: function () {
  979. return this.obj.length;
  980. }
  981. }
  982. return fs
  983. })());