Skip to content

Instantly share code, notes, and snippets.

@sapphire-al2o3
Created February 1, 2014 17:33
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 sapphire-al2o3/8755588 to your computer and use it in GitHub Desktop.
Save sapphire-al2o3/8755588 to your computer and use it in GitHub Desktop.
Twitterのbiggerアイコンをnormalアイコンに置き換える。
// ==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