Gazelle : Add Format

Add Format links appear in Better.php and Artist.php

当前为 2016-12-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @id whatcd-better-add-format
  3. // @name Gazelle : Add Format
  4. // @version 3
  5. // @namespace hateradio)))
  6. // @author hateradio
  7. // @description Add Format links appear in Better.php and Artist.php
  8. // @include http*://*what.cd/better.php*
  9. // @include http*://*what.cd/artist.php*
  10. // @include http*://*apollo.rip/better.php*
  11. // @include http*://*apollo.rip/artist.php*
  12. // @date 14 Feb 2012
  13. // @since 18 Dec 2011
  14. // ==/UserScript==
  15.  
  16. var gm_better = {
  17. path:document.location.pathname.substring(1).replace('.php',''),
  18. route:function(){
  19. var p;
  20. switch(this.path){
  21. case 'artist': p = '.group a[href^="torrents.php?id="]'; break;
  22. case 'better': p = '#content .thin table a[href*="torrents.php?id="]'; break;
  23. default: return false;
  24. }
  25. this.a = document.querySelectorAll(p);
  26. this.go();
  27. },
  28. go:function(){
  29. var a, p, i = this.a.length, l, f, s;
  30. while(i--){
  31. a = this.a[i];
  32. if(/id\=(\d+)/.test(a.href)){
  33. p = a.parentNode;
  34. f = document.createDocumentFragment();
  35. l = document.createElement('a');
  36. l.href = '/upload.php?groupid='+RegExp.lastParen;
  37. l.textContent = 'AF';
  38. l.title = 'Add Format';
  39. f.appendChild(document.createTextNode(' ['));
  40. f.appendChild(l);
  41. f.appendChild(document.createTextNode(']'));
  42. s = this.path === 'artist' ? a.nextElementSibling : a.nextElementSibling.nextElementSibling;
  43. p.insertBefore(f,s);
  44. }
  45. }
  46. }
  47. };
  48.  
  49. gm_better.route();