Created
February 1, 2014 17:33
-
-
Save sapphire-al2o3/8755588 to your computer and use it in GitHub Desktop.
Twitterのbiggerアイコンをnormalアイコンに置き換える。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @description Twitterのbiggerアイコンをnormalアイコンに書き換えます。 | |
// @include http*://twitter.com/* | |
// ==/UserScript== | |
(function() { | |
function changeAvatar() { | |
var imgs = document.querySelectorAll('img.js-action-profile-avatar'); | |
for(var i = 0; i < imgs.length; i++) { | |
imgs[i].src = imgs[i].src.replace(/bigger/, 'normal'); | |
} | |
} | |
changeAvatar(); | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(e) { | |
for(var i = 0; i < e.addedNodes.length; i++) { | |
changeAvatar(); | |
} | |
}); | |
}); | |
var config = { | |
attributes: false, | |
childList: true, | |
characterData: false, | |
subtree: true | |
}; | |
var target = document.getElementById('stream-items-id'); | |
observer.observe(document.body, config); | |
window.addEventListener('popstate', function(e) { | |
if(e.state) { | |
changeAvatar(); | |
} | |
}, true); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment