// ==UserScript== // @name Pouet 'prod list thumbnailer' // @description add a thumbnail for each prod in prod list // @include http://www.pouet.net/prodlist.php* // ==/UserScript== /* 2012.08.24 Tigrou (ind). Use it at your own risk */ !(function () { // add a thumbnail for each prod in prod list var table = document.querySelectorAll('table[cellspacing="1"][cellpadding="2"]')[1]; var path = 'http://www.pouet.net/screenshots/'; var ext = ['.png', '.jpg', '.gif']; for (var i = 0; i < table.rows.length; i++) { var row = table.rows[i]; var match = row.cells[0].innerHTML.match(/prod.php\?which=(\d+)/); if (match) { var cell = row.insertCell(0); var prodid = match[1]; var src = window.localStorage.getItem(prodid); if (src != "none") { var img = document.createElement('img'); img.width = '120'; img.height = '80'; img.prodid = prodid; img.tries = 0; img.onerror = function (evt) { this.tries++; if (this.tries < ext.length) this.src = path + this.prodid + ext[this.tries]; else { window.localStorage.setItem(this.prodid, "none"); this.parentNode.removeChild(this); } }; img.onload = function (evt) { window.localStorage.setItem(this.prodid, this.src); }; if (src == null) src = path + prodid + ext[img.tries]; img.src = src; cell.appendChild(img); } } else row.insertCell(0); } })();