Skip to content

Instantly share code, notes, and snippets.

@mdusher
Last active July 15, 2016 01:13
Show Gist options
  • Save mdusher/3344cf57443298d90038db46fb690da8 to your computer and use it in GitHub Desktop.
Save mdusher/3344cf57443298d90038db46fb690da8 to your computer and use it in GitHub Desktop.
Improves usability of Twitter Web
// ==UserScript==
// @name ImproveTwitterWeb
// @version 0.1
// @description Improves usability of Twitter Web
// @author Michael Usher
// @match https://www.twitter.com/*
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
var $ = window.jQuery;
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
$(document).ready(function(){
var update_css = `
/* Hide any content that is dismissable */
.dismissible-content {
display: none;
}
/* Make videos smaller */
.AdaptiveMedia-video {
width: 100px;
}
/* Make images smaller */
.AdaptiveMedia.is-square {
width: 100px;
height: auto;
}
/* Remove top position from thumbnails */
.AdaptiveMedia-photoContainer img {
top: initial !important;
}
/* Double image containers */
div.AdaptiveMedia-doublePhoto div.AdaptiveMedia-halfwidthPhoto {
width: 100px;
}
/* Hide large images on links */
.SummaryCard-image {
display: none;
}
/* Show links */
a.twitter-timeline-link.u-hidden {
display: inline-block !important;
margin-left: 5px;
}
/* Hide large summary cards */
div.card-type-summary,
div.card-type-summary_large_image {
display: none;
}
`;
$("<style>").prop("type", "text/css").html(update_css).appendTo("head");
var obs = new MutationObserver (clickNewTweetHandler);
var obsConfig = { childList: true, characterData: true, attributes: true, subtree: true };
var obsRoot = $('.stream-container');
obsRoot.each(function() { obs.observe(this, obsConfig); });
function clickNewTweetHandler(m) {
if ($('.new-tweets-bar').length > 0) { $('.new-tweets-bar').click() ; }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment