Skip to content

Instantly share code, notes, and snippets.

@esolitos
Created June 15, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esolitos/940d9de685e5fec9a6b5 to your computer and use it in GitHub Desktop.
Save esolitos/940d9de685e5fec9a6b5 to your computer and use it in GitHub Desktop.
HDAccess Expand Poster Script
function findPosterLink(baseElement) {
if ( !baseElement ) {
return false;
}
// console.warn('findPosterLink');
var linkCells = baseElement.getElementsByClassName('torrents');
if ( linkCells.length ) {
var linkElem = linkCells[0].getElementsByTagName('a');
if ( linkElem.length > 0 && linkElem[0].hasAttribute('onmouseover') ) {
var string = linkElem[0].getAttribute('onmouseover');
var result = string.match( /.+src=\\'([a-z0-9\/\.]+\.(?:jpg|png))\\'.+/i );
if ( result && result.length >= 2 ) {
return result[1];
}
else {
console.log(result);
}
}
}
return false;
}
function addPosterColumnToRow(rowElement, imagePath) {
var imageElem = rowElement.getElementsByTagName("img")[0];
imageElem.setAttribute('src', imagePath);
imageElem.setAttribute('style',"width:100%;height:auto;");
}
var all_items=document.querySelectorAll('tr.browse_color');
for(item_id in all_items){
var current=all_items[item_id];
var path = findPosterLink(current);
addPosterColumnToRow(current, path);
};
javascript:function findPosterLink(t){if(!t)return!1;var e=t.getElementsByClassName("torrents");if(e.length){var r=e[0].getElementsByTagName("a");if(r.length>0&&r[0].hasAttribute("onmouseover")){var n=r[0].getAttribute("onmouseover"),o=n.match(/.+src=\\'([a-z0-9\/\.]+\.(?:jpg|png))\\'.+/i);if(o&&o.length>=2)return o[1];console.log(o)}}return!1}function addPosterColumnToRow(t,e){var r=t.getElementsByTagName("img")[0];r.setAttribute("src",e),r.setAttribute("style","width:100%;height:auto;")}var all_items=document.querySelectorAll("tr.browse_color");for(item_id in all_items){var current=all_items[item_id],path=findPosterLink(current);addPosterColumnToRow(current,path)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment