Gazelle : Add Format

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @id             whatcd-better-add-format
// @name           Gazelle : Add Format
// @version        3
// @namespace      hateradio)))
// @author         hateradio
// @description    Add Format links appear in Better.php and Artist.php
// @include        http*://*what.cd/better.php*
// @include        http*://*what.cd/artist.php*
// @include        http*://*apollo.rip/better.php*
// @include        http*://*apollo.rip/artist.php*
// @date           14 Feb 2012
// @since          18 Dec 2011
// ==/UserScript==

var gm_better = {
	path:document.location.pathname.substring(1).replace('.php',''),
	route:function(){
		var p;
		switch(this.path){
			case 'artist': p = '.group a[href^="torrents.php?id="]'; break;
			case 'better': p = '#content .thin table a[href*="torrents.php?id="]'; break;
			default: return false;
		}
		this.a = document.querySelectorAll(p);
		this.go();
	},
	go:function(){
		var a, p, i = this.a.length, l, f, s;
		while(i--){
			a = this.a[i];
			if(/id\=(\d+)/.test(a.href)){
				p = a.parentNode;
				f = document.createDocumentFragment();
				l = document.createElement('a');
				l.href = '/upload.php?groupid='+RegExp.lastParen;
				l.textContent = 'AF';
				l.title = 'Add Format';
				f.appendChild(document.createTextNode(' ['));
				f.appendChild(l);
				f.appendChild(document.createTextNode(']'));
				s = this.path === 'artist' ? a.nextElementSibling : a.nextElementSibling.nextElementSibling;
				p.insertBefore(f,s);
			}
		}
	}
};

gm_better.route();