Skip to content

Instantly share code, notes, and snippets.

@dtipson
Last active December 15, 2015 14:19
Show Gist options
  • Save dtipson/5273244 to your computer and use it in GitHub Desktop.
Save dtipson/5273244 to your computer and use it in GitHub Desktop.
function jandocme(){
(function($){
var i = 0, windowWidth = $(window).width();
$('img').each(function(){
var $el = $(this),
w = $el.width(),
h = $el.height(),
src = $el.attr('src');
if(w>16 && h>16 && (src.indexOf('1px')===-1) && h<1000) { $el.attr('src','http://placejandoc.jgre.co/'+w+'-'+h+'?'+(i++)); }
});
$('iframe,embed').each(function(){
var $el = $(this),
w = $el.width(),
h = $el.height(),
offleft = $el.offset().left;
if(w>50 && h>50 && ((offleft + w)>0) && h<1000){ $el.replaceWith('<img src="http://placejandoc.jgre.co/'+w+'-'+h+'?'+(i++)+'" style="width: '+w+'px !important;height: '+h+'px !important;">'); }
});
$("*").filter(
window.getComputedStyle ?
function() {
return "none" !== document.defaultView.getComputedStyle(this, null).getPropertyValue('background-image');
} :
function() {
return "none" !== this.currentStyle.backgroundImage;
}).filter(function(){
return $(this).css('background-image').indexOf('url(')>-1;
}).each(function(){
var $el = $(this),
w = $el.width(),
h = $el.height(),
src = $el.css('background-image').toLowerCase();
if(w>16 && h>20 &&
(src.indexOf('bg-')===-1)
&& (src.indexOf('/layout/')===-1)
&& (src.indexOf('border')===-1)
&& (src.indexOf('dotted')===-1)
&& (src.indexOf('bullet')===-1)
&& (src.indexOf('gradient')===-1)
&& (src.indexOf('-bg')===-1)
&& (src.indexOf('grid-')===-1)
&& (src.indexOf('.carrot')===-1)
&& (src.indexOf('_divider')===-1)
&& (src.indexOf('_bull.')===-1)
&& (src.indexOf('bg_')===-1)
&& (src.indexOf('.bg')===-1)
&& (src.indexOf('bg.')===-1)
&& w<800 && h<600) {
$el.css({'background-image':'url(http://placejandoc.jgre.co/'+w+'-'+h+'?'+(i++)+')','background-position':'0 0'});
}
});
}(jQuery||bQuery));
}
if (!($ = window.jQuery)) {
var script = document.createElement( 'script' );
script.src = '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
script.onload=jandocme;
document.body.appendChild(script);
}
else {
jandocme()
}
/*
javascript: (function () {var jsCode = document.createElement('script');jsCode.setAttribute('src', 'https://gist.github.com/dtipson/5273244/raw/d3727f43bf5502766dd0c711a920f48c36126330/janedocme.js');document.body.appendChild(jsCode);}());
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment