Skip to content

Instantly share code, notes, and snippets.

@ykzts
Forked from gyuque/gist:6181331
Last active December 20, 2015 19:09
Show Gist options
  • Save ykzts/6181339 to your computer and use it in GitHub Desktop.
Save ykzts/6181339 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name TOUAHANTEN
// @namespace gyuque
// @include http://gigazine.net/*
// @version 2
// ==/UserScript==
(function() {
'use strict';
var matchesSelector = HTMLElement.prototype.matchesSelector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.mozMatchesSelector;
var selector = '[href*="flickr.com"] img';
var touaHanten = 'http://24.media.tumblr.com/91485b94990bcf27b97c0917c59e50e1/tumblr_mr713drDFo1qz5devo1_400.png';
function fuckGigazine(event) {
if (!matchesSelector.call(this, selector) || this.getAttribute('src') === touaHanten) {
return;
}
if (event) {
event.preventDefault();
this.removeEventListener('load', fuckGigazine, false);
}
this.setAttribute('src', touaHanten);
return false;
}
Array.prototype.forEach.call(document.querySelectorAll(selector), function(img) {
if (img.classList.contains('lazy')) {
img.addEventListener('load', fuckGigazine, false);
} else {
fuckGigazine.call(img);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment