Guest User

Untitled

a guest
Mar 10th, 2015
231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        MAL Radio Filter
  3. // @namespace   myanimelist.net
  4. // @include     http://myanimelist.net/animelist/*
  5. // @require     http://code.jquery.com/jquery-latest.min.js
  6. // @require     http://code.jquery.com/ui/1.10.2/jquery-ui.js
  7. // @description This script adds four radio buttons (All, TV, Movie, OVA & Special) that allows you to show just one type of anime at a time. e.g. if you click on the "Movie" button, it will show you only the movies, and hide TV series, OVAs and other stuff.
  8. // @version     1.5.2
  9. // @grant       none
  10. // ==/UserScript==
  11.  
  12. var typevar='All';
  13. var scorevar='All';
  14. var progressvar='All';
  15. var airingvar='All';
  16. var ratingvar='All';
  17. var equalscore='0';
  18. var select=1;
  19. var ratselect=1;
  20. var rangescore='';
  21. var animename='';
  22.  
  23. function myFunction() {
  24.     var x=$(this).val();
  25.     if ($(this).attr('class')=='type') { typevar=x; }
  26.     else if ($(this).attr('class')=='score') { scorevar=x; }
  27.     else if ($(this).attr('class')=='progress') { progressvar=x; begin=progressvar.split('-')[0]; end=progressvar.split('-')[1]; }
  28.     else if ($(this).attr('class')=='airing') { airingvar=x; }
  29.     else if ($(this).attr('class')=='rating') { ratingvar=x; }
  30.     else if ($(this).attr('id')=='select') { select=parseInt(x); }
  31.     else if ($(this).attr('id')=='ratselect') { ratselect=parseInt(x); }
  32.     else if ($(this).attr('id')=='equal') { equalscore=x; }
  33.     else if ($(this).attr('id')=='name') { animename=x; }
  34.    
  35.     $("tr:has(.td1,.td2)").hide();
  36.     var exp="tr";
  37.    
  38.     $.expr[':'].ratingEquals = $.expr.createPseudo(function(arg) {
  39.         return function( elem ) {
  40.             return $(elem).text().match(" " + arg + "$");
  41.         };
  42.     });
  43.    
  44.     if (typevar!='All' && select) { exp=exp+":has(td[width='50']:contains('"+typevar+"'))"; }
  45.     else if (typevar!='All' && !select) { exp=exp+":not(:has(td[width='50']:contains('"+typevar+"')))"; }
  46.     if (airingvar=='Airing') { exp=exp+":contains('Airing')"; }
  47.     else if (airingvar=='Not Airing') { exp=exp+":not(:contains('Airing'))"; }
  48.     if (scorevar!='All' && equalscore=='0') { exp=exp+":has(td[width='45']:contains('"+scorevar+"'))"; }
  49.     else if (scorevar!='All' && equalscore=='1') { exp=exp+":has(td[width='45']:not(:contains('"+scorevar+"')))"; }
  50.     if (ratingvar!='All' && ratselect) { exp=exp+":has(td[width='50']:ratingEquals('"+ratingvar+"'))"; }
  51.     else if (ratingvar!='All' && !ratselect) { exp=exp+":not(:has(td[width='50']:ratingEquals('"+ratingvar+"')))"; }
  52.     if (exp == "tr") { exp=exp+":has(td)"; }
  53.    
  54.     if (progressvar!='All') { exp = $(exp).filter(function() { return parseInt($("td[width='70']", this).text()) < parseInt(end) && parseInt($("td[width='70']", this).text()) >= parseInt(begin); }); }
  55.     if (scorevar!='All' && equalscore=='2') { exp=$(exp).filter(function() { return parseInt($("td[width='45']", this).text()) >= parseInt(scorevar); }); }
  56.     else if (scorevar!='All' && equalscore=='3') { exp=$(exp).filter(function() { return parseInt($("td[width='45']", this).text()) <= parseInt(scorevar); }); }
  57.     else if (equalscore=='4') { exp=$(exp).filter(function() { return parseInt($("td[width='45']", this).text()) <= parseInt(scoreend) && parseInt($("td[width='45']", this).text()) >= parseInt(scorebegin); }); }
  58.    
  59.     $(exp).each(function(){
  60.         if ($(this).text().search(new RegExp(animename, "i")) >=0) { $(this).show(); }
  61.     });
  62. }
  63.  
  64. $(document).ready(function() {
  65.     $(".type,.score,.progress,.airing,select,.rating,ratselect").click(myFunction);
  66.     $("#name").focusin(function() {
  67.         if (this.value=='Enter a title') { $(this).val(''); }
  68.     });
  69.     $("#name").focusout(function() {
  70.         if (this.value=='') { $(this).val('Enter a title'); }
  71.     });
  72.     $("#name").keyup(myFunction);
  73.    
  74.     $("#choose").click(function() {
  75.         var bha = prompt('Choose score range separated by a minus','6-8');
  76.         $(this).text(bha);
  77.         rangescore=bha;
  78.         scorebegin=rangescore.split('-')[0];
  79.         scoreend=rangescore.split('-')[1];
  80.         myFunction();
  81.     });
  82.  
  83.     $(function() {
  84.         $(".drag").draggable();
  85.     });
  86.    
  87.     /*$(".drag div").hide();
  88.     $(".drag").hover(function() {
  89.         $("div", this).stop(true, true).slideToggle(200);
  90.     })*/
  91. });
  92.  
  93.  
  94. table=document.createElement('table');
  95. table.className='drag';
  96. table.style.right='190px';
  97. table2=document.createElement('table');
  98. table2.className='drag';
  99. table2.style.right='40px';
  100. table3=document.createElement('table');
  101. table3.className='drag';
  102. table3.style.right='190px';
  103. table4=document.createElement('table');
  104. table4.className='drag';
  105. table4.style.right='70px';
  106. table5=document.createElement('table');
  107. table5.className='drag';
  108. table5.style.right='190px';
  109.  
  110. type=document.createElement('td');
  111. type.className='td';
  112. score=document.createElement('td');
  113. score.className='td';
  114. progress=document.createElement('td');
  115. progress.className='td';
  116. airing=document.createElement('td');
  117. airing.className='td';
  118. rating=document.createElement('td');
  119. rating.className='td';
  120.  
  121. headtype=document.createElement('tr');
  122. headscore=document.createElement('tr');
  123. headprogress=document.createElement('tr');
  124. headairing=document.createElement('tr');
  125. headrating=document.createElement('tr');
  126.  
  127. divtype=document.createElement('div');
  128. divscore=document.createElement('div');
  129. divprogress=document.createElement('div');
  130. divairing=document.createElement('div');
  131. divrating=document.createElement('div');
  132.  
  133. imagetype=document.createElement('div');
  134. imagetype.className='group_header';
  135. imagetype.innerHTML='type';
  136. imagescore=document.createElement('div');
  137. imagescore.className='group_header';
  138. imagescore.innerHTML='score';
  139. imageprogress=document.createElement('div');
  140. imageprogress.className='group_header';
  141. imageprogress.innerHTML='progress';
  142. imageairing=document.createElement('div');
  143. imageairing.className='group_header';
  144. imageairing.innerHTML='status';
  145. imagerating=document.createElement('div');
  146. imagerating.className='group_header';
  147. imagerating.innerHTML='rating';
  148.  
  149. tr1=document.createElement('tr');
  150. tr2=document.createElement('tr');
  151. tr3=document.createElement('tr');
  152. tr4=document.createElement('tr');
  153. tr5=document.createElement('tr');
  154. tr6=document.createElement('tr');
  155. tr7=document.createElement('tr');
  156. tr8=document.createElement('tr');
  157. tr9=document.createElement('tr');
  158. tr10=document.createElement('tr');
  159. tr11=document.createElement('tr');
  160. tr12=document.createElement('tr');
  161. tr13=document.createElement('tr');
  162. tr14=document.createElement('tr');
  163. tr15=document.createElement('tr');
  164. tr16=document.createElement('tr');
  165. tr17=document.createElement('tr');
  166. tr18=document.createElement('tr');
  167. tr19=document.createElement('tr');
  168. tr20=document.createElement('tr');
  169. tr21=document.createElement('tr');
  170. tr22=document.createElement('tr');
  171. tr23=document.createElement('tr');
  172. tr24=document.createElement('tr');
  173. tr25=document.createElement('tr');
  174. tr26=document.createElement('tr');
  175. tr27=document.createElement('tr');
  176. tr28=document.createElement('tr');
  177. tr29=document.createElement('tr');
  178. tr30=document.createElement('tr');
  179. tr31=document.createElement('tr');
  180. tr32=document.createElement('tr');
  181. tr33=document.createElement('tr');
  182. tr34=document.createElement('tr');
  183. tr35=document.createElement('tr');
  184. tr36=document.createElement('tr');
  185. tr37=document.createElement('tr');
  186.  
  187. alltype=document.createElement('input');
  188. alltype.className='type';
  189. alltype.value='All';
  190. alltype.checked='yes';
  191. alltypetext=document.createElement('a');
  192. alltypetext.innerHTML='All';
  193.  
  194. tv=document.createElement('input');
  195. tv.className='type';
  196. tv.value='TV';
  197. tvtext=document.createElement('a');
  198. tvtext.innerHTML='TV';
  199.  
  200. movie=document.createElement('input');
  201. movie.className='type';
  202. movie.value='Movie';
  203. movietext=document.createElement('a');
  204. movietext.innerHTML='Movie';
  205.  
  206. ova=document.createElement('input');
  207. ova.className='type';
  208. ova.value='OVA';
  209. ovatext=document.createElement('a');
  210. ovatext.innerHTML='OVA';
  211.  
  212. ona=document.createElement('input');
  213. ona.className='type';
  214. ona.value='ONA';
  215. onatext=document.createElement('a');
  216. onatext.innerHTML='ONA';
  217.  
  218. special=document.createElement('input');
  219. special.className='type';
  220. special.value='Special';
  221. specialtext=document.createElement('a');
  222. specialtext.innerHTML='Special';
  223.  
  224.  
  225. menutype=document.createElement('select');
  226. menutype.id='select';
  227.  
  228. select=document.createElement('option');
  229. select.value='1';
  230. select.selected='selected';
  231. select.innerHTML='Select';
  232.  
  233. remove=document.createElement('option');
  234. remove.value='0';
  235. remove.innerHTML='Remove';
  236.  
  237.  
  238. allscore=document.createElement('input');
  239. allscore.className='score';
  240. allscore.value='All';
  241. allscore.checked='yes';
  242. allscoretext=document.createElement('a');
  243. allscoretext.innerHTML='All';
  244.  
  245. score10=document.createElement('input');
  246. score10.className='score';
  247. score10.value='10';
  248. score10text=document.createElement('a');
  249. score10text.innerHTML='10';
  250.  
  251. score9=document.createElement('input');
  252. score9.className='score';
  253. score9.value='9';
  254. score9text=document.createElement('a');
  255. score9text.innerHTML='9';
  256.  
  257. score8=document.createElement('input');
  258. score8.className='score';
  259. score8.value='8';
  260. score8text=document.createElement('a');
  261. score8text.innerHTML='8';
  262.  
  263. score7=document.createElement('input');
  264. score7.className='score';
  265. score7.value='7';
  266. score7text=document.createElement('a');
  267. score7text.innerHTML='7';
  268.  
  269. score6=document.createElement('input');
  270. score6.className='score';
  271. score6.value='6';
  272. score6text=document.createElement('a');
  273. score6text.innerHTML='6';
  274.  
  275. score5=document.createElement('input');
  276. score5.className='score';
  277. score5.value='5';
  278. score5text=document.createElement('a');
  279. score5text.innerHTML='5';
  280.  
  281. score4=document.createElement('input');
  282. score4.className='score';
  283. score4.value='4';
  284. score4text=document.createElement('a');
  285. score4text.innerHTML='4';
  286.  
  287. score3=document.createElement('input');
  288. score3.className='score';
  289. score3.value='3';
  290. score3text=document.createElement('a');
  291. score3text.innerHTML='3';
  292.  
  293. score2=document.createElement('input');
  294. score2.className='score';
  295. score2.value='2';
  296. score2text=document.createElement('a');
  297. score2text.innerHTML='2';
  298.  
  299. score1=document.createElement('input');
  300. score1.className='score';
  301. score1.value='1';
  302. score1text=document.createElement('a');
  303. score1text.innerHTML='1';
  304.  
  305. scorenull=document.createElement('input');
  306. scorenull.className='score';
  307. scorenull.value='-';
  308. scorenulltext=document.createElement('a');
  309. scorenulltext.innerHTML='-';
  310.  
  311.  
  312. menuscore=document.createElement('select');
  313. menuscore.id='equal';
  314.  
  315. equal=document.createElement('option');
  316. equal.value='0';
  317. equal.selected='selected';
  318. equal.innerHTML='Equal to';
  319.  
  320. notequal=document.createElement('option');
  321. notequal.value='1';
  322. notequal.innerHTML='Not equal to';
  323.  
  324. greater=document.createElement('option');
  325. greater.value='2';
  326. greater.innerHTML='Greater than';
  327.  
  328. smaller=document.createElement('option');
  329. smaller.value='3';
  330. smaller.innerHTML='Smaller than';
  331.  
  332. choose=document.createElement('option');
  333. choose.value='4';
  334. choose.id='choose';
  335. choose.innerHTML='Choose range';
  336.  
  337.  
  338. namee=document.createElement('input');
  339. namee.id='name';
  340. namee.type='text';
  341. namee.style.width='80px';
  342. namee.value='Enter a title';
  343.  
  344. allprogress=document.createElement('input');
  345. allprogress.className='progress';
  346. allprogress.value='All';
  347. allprogress.checked='yes';
  348. allprogresstext=document.createElement('a');
  349. allprogresstext.innerHTML='All';
  350.  
  351. short=document.createElement('input');
  352. short.className='progress';
  353. short.value='0-25';
  354. shorttext=document.createElement('a');
  355. shorttext.innerHTML='Short';
  356.  
  357. medium=document.createElement('input');
  358. medium.className='progress';
  359. medium.value='25-50';
  360. mediumtext=document.createElement('a');
  361. mediumtext.innerHTML='Medium';
  362.  
  363. long=document.createElement('input');
  364. long.className='progress';
  365. long.value='50-100';
  366. longtext=document.createElement('a');
  367. longtext.innerHTML='Long';
  368.  
  369. infinite=document.createElement('input');
  370. infinite.className='progress';
  371. infinite.value='100-10000';
  372. infinitetext=document.createElement('a');
  373. infinitetext.innerHTML='Infinite';
  374.  
  375.  
  376. allairing=document.createElement('input');
  377. allairing.className='airing';
  378. allairing.value='All';
  379. allairing.checked='yes';
  380. allairingtext=document.createElement('a');
  381. allairingtext.innerHTML='All';
  382.  
  383. airingt=document.createElement('input');
  384. airingt.className='airing';
  385. airingt.value='Airing';
  386. airingtext=document.createElement('a');
  387. airingtext.innerHTML='Airing';
  388.  
  389. notairing=document.createElement('input');
  390. notairing.className='airing';
  391. notairing.value='Not Airing';
  392. notairingtext=document.createElement('a');
  393. notairingtext.innerHTML='Not Airing';
  394.  
  395.  
  396. allrating=document.createElement('input');
  397. allrating.className='rating';
  398. allrating.value='All';
  399. allrating.checked='yes';
  400. allratingtext=document.createElement('a');
  401. allratingtext.innerHTML='All';
  402.  
  403. grating=document.createElement('input');
  404. grating.className='rating';
  405. grating.value='G';
  406. gratingtext=document.createElement('a');
  407. gratingtext.innerHTML='G';
  408.  
  409. pgrating=document.createElement('input');
  410. pgrating.className='rating';
  411. pgrating.value='PG';
  412. pgratingtext=document.createElement('a');
  413. pgratingtext.innerHTML='PG';
  414.  
  415. pg13rating=document.createElement('input');
  416. pg13rating.className='rating';
  417. pg13rating.value='PG-13';
  418. pg13ratingtext=document.createElement('a');
  419. pg13ratingtext.innerHTML='PG-13';
  420.  
  421. rrating=document.createElement('input');
  422. rrating.className='rating';
  423. rrating.value='R';
  424. rratingtext=document.createElement('a');
  425. rratingtext.innerHTML='R';
  426.  
  427. rprating=document.createElement('input');
  428. rprating.className='rating';
  429. rprating.value='R\\+';
  430. rpratingtext=document.createElement('a');
  431. rpratingtext.innerHTML='R+';
  432.  
  433. rxrating=document.createElement('input');
  434. rxrating.className='rating';
  435. rxrating.value='Rx';
  436. rxratingtext=document.createElement('a');
  437. rxratingtext.innerHTML='Rx';
  438.  
  439. menurating=document.createElement('select');
  440. menurating.id='ratselect';
  441.  
  442. ratselect=document.createElement('option');
  443. ratselect.value='1';
  444. ratselect.selected='selected';
  445. ratselect.innerHTML='Select';
  446.  
  447. ratremove=document.createElement('option');
  448. ratremove.value='0';
  449. ratremove.innerHTML='Remove';
  450.  
  451. document.body.appendChild(table);
  452. table.appendChild(type);
  453. type.appendChild(headtype);
  454.     headtype.appendChild(imagetype);
  455. type.appendChild(divtype);
  456. divtype.appendChild(tr27);
  457.     tr27.appendChild(menutype);
  458.         menutype.appendChild(select);
  459.         menutype.appendChild(remove);
  460. divtype.appendChild(tr16);
  461.     tr16.appendChild(alltype);
  462.     tr16.appendChild(alltypetext);
  463. divtype.appendChild(tr1);
  464.     tr1.appendChild(tv);
  465.     tr1.appendChild(tvtext);
  466. divtype.appendChild(tr2);
  467.     tr2.appendChild(movie);
  468.     tr2.appendChild(movietext);
  469. divtype.appendChild(tr3);
  470.     tr3.appendChild(ova);
  471.     tr3.appendChild(ovatext);
  472. divtype.appendChild(tr23);
  473.     tr23.appendChild(ona);
  474.     tr23.appendChild(onatext);
  475. divtype.appendChild(tr4);
  476.     tr4.appendChild(special);
  477.     tr4.appendChild(specialtext);
  478.    
  479. document.body.appendChild(table2);
  480. table2.appendChild(score);
  481. score.appendChild(headscore);
  482.     headscore.appendChild(imagescore);
  483. score.appendChild(divscore);
  484. divscore.appendChild(tr28);
  485.     tr28.appendChild(menuscore);
  486.         menuscore.appendChild(equal);
  487.         menuscore.appendChild(notequal);
  488.         menuscore.appendChild(greater);
  489.         menuscore.appendChild(smaller);
  490.         menuscore.appendChild(choose);
  491. divscore.appendChild(tr17);
  492.     tr17.appendChild(allscore);
  493.     tr17.appendChild(allscoretext);
  494. divscore.appendChild(tr5);
  495.     tr5.appendChild(score10);
  496.     tr5.appendChild(score10text);
  497. divscore.appendChild(tr6);
  498.     tr6.appendChild(score9);
  499.     tr6.appendChild(score9text);
  500. divscore.appendChild(tr7);
  501.     tr7.appendChild(score8);
  502.     tr7.appendChild(score8text);
  503. divscore.appendChild(tr8);
  504.     tr8.appendChild(score7);
  505.     tr8.appendChild(score7text);
  506. divscore.appendChild(tr9);
  507.     tr9.appendChild(score6);
  508.     tr9.appendChild(score6text);
  509. divscore.appendChild(tr10);
  510.     tr10.appendChild(score5);
  511.     tr10.appendChild(score5text);
  512. divscore.appendChild(tr11);
  513.     tr11.appendChild(score4);
  514.     tr11.appendChild(score4text);
  515. divscore.appendChild(tr12);
  516.     tr12.appendChild(score3);
  517.     tr12.appendChild(score3text);
  518. divscore.appendChild(tr13);
  519.     tr13.appendChild(score2);
  520.     tr13.appendChild(score2text);
  521. divscore.appendChild(tr14);
  522.     tr14.appendChild(score1);
  523.     tr14.appendChild(score1text);
  524. divscore.appendChild(tr15);
  525.     tr15.appendChild(scorenull);
  526.     tr15.appendChild(scorenulltext);
  527.    
  528. document.body.appendChild(table3);
  529. table3.appendChild(progress);
  530. progress.appendChild(headprogress);
  531.     headprogress.appendChild(imageprogress);
  532. progress.appendChild(divprogress);
  533. divprogress.appendChild(tr29);
  534.     tr29.appendChild(namee);
  535. divprogress.appendChild(tr18);
  536.     tr18.appendChild(allprogress);
  537.     tr18.appendChild(allprogresstext);
  538. divprogress.appendChild(tr19);
  539.     tr19.appendChild(short);
  540.     tr19.appendChild(shorttext);
  541. divprogress.appendChild(tr20);
  542.     tr20.appendChild(medium);
  543.     tr20.appendChild(mediumtext);
  544. divprogress.appendChild(tr21);
  545.     tr21.appendChild(long);
  546.     tr21.appendChild(longtext);
  547. divprogress.appendChild(tr22);
  548.     tr22.appendChild(infinite);
  549.     tr22.appendChild(infinitetext);
  550.    
  551. document.body.appendChild(table4);
  552. table4.appendChild(airing);
  553. airing.appendChild(headairing);
  554.     headairing.appendChild(imageairing);
  555. airing.appendChild(divairing);
  556. divairing.appendChild(tr24);
  557.     tr24.appendChild(allairing);
  558.     tr24.appendChild(allairingtext);
  559. divairing.appendChild(tr25);
  560.     tr25.appendChild(airingt);
  561.     tr25.appendChild(airingtext);
  562. divairing.appendChild(tr26);
  563.     tr26.appendChild(notairing);
  564.     tr26.appendChild(notairingtext);
  565.  
  566. document.body.appendChild(table5);
  567. table5.appendChild(rating);
  568. rating.appendChild(headrating);
  569.     headrating.appendChild(imagerating);
  570. rating.appendChild(divrating);
  571. divrating.appendChild(tr30);
  572.     tr30.appendChild(menurating);
  573.         menurating.appendChild(ratselect);
  574.         menurating.appendChild(ratremove);
  575. divrating.appendChild(tr31);
  576.     tr31.appendChild(allrating);
  577.     tr31.appendChild(allratingtext);
  578. divrating.appendChild(tr32);
  579.     tr32.appendChild(grating);
  580.     tr32.appendChild(gratingtext);
  581. divrating.appendChild(tr33);
  582.     tr33.appendChild(pgrating);
  583.     tr33.appendChild(pgratingtext);
  584. divrating.appendChild(tr34);
  585.     tr34.appendChild(pg13rating);
  586.     tr34.appendChild(pg13ratingtext);
  587. divrating.appendChild(tr35);
  588.     tr35.appendChild(rrating);
  589.     tr35.appendChild(rratingtext);
  590. divrating.appendChild(tr36);
  591.     tr36.appendChild(rprating);
  592.     tr36.appendChild(rpratingtext);
  593. divrating.appendChild(tr37);
  594.     tr37.appendChild(rxrating);
  595.     tr37.appendChild(rxratingtext);
  596.  
  597.    
  598. $(".drag").css({"position":"fixed","top":"100px","background":"white","opacity":"0.7","padding":"10px","borderRadius":"10px"});
  599. $(".group_header").css({"font-size":"14pt","font-family":"Verdana, Arial, sans-serif","font-weight":"normal","color":"black"});
  600. table3.style.top='325px';
  601. table4.style.top='465px';
  602. table5.style.top='525px';
  603. $(".td a").css({"color":"black"});
  604. $(".type").attr({type:"radio",name:"group1"});
  605. $(".score").attr({type:"radio",name:"group2"});
  606. $(".progress").attr({type:"radio",name:"group3"});
  607. $(".airing").attr({type:"radio",name:"group4"});
  608. $(".select").attr({type:"radio",name:"group5"});
  609. $(".equal").attr({type:"radio",name:"group6"});
  610. $(".rating").attr({type:"radio",name:"group7"});
RAW Paste Data