// ==UserScript== // @include https://imgur.com/* // ==/UserScript== if (window.top==window) (function(opera){ var maxImages = 123; var thumb = 'l'; var once = true; var ScriptName = 'imgur.com.js v2'; //e.element.text function blockScripts(e){ if (e.element.src.indexOf('api.imgur.com')==-1) { e.preventDefault(); if (once) once = opera.postError(ScriptName+' block: * '+e.element.src); } } opera.addEventListener("BeforeExternalScript",blockScripts,false); opera.addEventListener("BeforeScript",blockScripts,false); function_name = function(j){ //alert(JSON.stringify(j,null,'\t')) var html = ['<style>body {padding:8px} </style>','<h3>'+j.data.title+'</h3>',j.data.images_count+' images']; var im = j.data.images || [j.data]; if (im.length>maxImages) html.push('<br>First '+maxImages+':'); html.push('<br><br>'); var tmp = Math.min(im.length,maxImages); for (var i=0; i<tmp; i++) { if (im[i].title) html.push('<h3>'+im[i].title+'</h3>'); html.push('<a href="'+im[i].link+'"><img src="https://i.imgur.com/'+im[i].id+thumb+'.jpg"/></a>'); if (im[i].description) html.push('<br/>'+im[i].description); html.push('<br><br><br>'); } html.push('</div></html>'); html = html.join(''); document.body.innerHTML = html; } document.addEventListener('DOMContentLoaded',function(){ var p = location.pathname.split('/'); var id = p[2]; var t = {a:'album',gallery:'gallery'}[p[1]]; if (p.length==2 && !t && !id) { t='image'; id = p[1]; } if (t) { var s = document.createElement('script'); s.src = 'https://api.imgur.com/3/'+t+'/'+id+'.json?client_id=546c25a59c58ad7&callback=function_name'; document.body.appendChild(s); } else { var divs = document.querySelectorAll('div.post-image-container[id]'); for (var i=0; i<divs.length; i++){ var id = divs[i].id; divs[i].innerHTML='<a href="https://i.imgur.com/'+id+'.jpg"><img src="https://i.imgur.com/'+id+thumb+'.jpg"></a>'; } } },false); })(opera) |