wang867gmail.com / e-hentai gallery dl link patch

// ==UserScript==
// @name        e-hentai gallery dl link patch
// @namespace   
// @include   http://g.e-hentai.org/g/*
// @include   https://g.e-hentai.org/g/*
// @include   http://e-hentai.org/g/*
// @include   https://e-hentai.org/g/*
// @description e-hentai gallery dl link patch
// @version     0.0.3
// @grant       none
// ==/UserScript==
// 

var tdpop = document.getElementsByTagName("a"), i = 0, td;
var pattern_tdpop = /Torrent Download/;
var pattern_tdpop2 = /Archive Download/;

while (tdpop[i]){
  td = tdpop[i];
  if (td.textContent.match(pattern_tdpop) || td.textContent.match(pattern_tdpop2)){
    var dl_lnk = td.getAttribute("onclick").match(/\'(.*)\'/)[1];
    td.removeAttribute("onclick");
    td.removeAttribute("href");
    td.setAttribute("href", dl_lnk);
  }
  i++;
}