Skip to content

Instantly share code, notes, and snippets.

@RoxasShadow
Last active April 15, 2018 00:40
Show Gist options
  • Save RoxasShadow/031eda7f62d09bc8d61d1d5739038329 to your computer and use it in GitHub Desktop.
Save RoxasShadow/031eda7f62d09bc8d61d1d5739038329 to your computer and use it in GitHub Desktop.
replace all the images with their HQ version (that is, the one that's been uploaded originally)
// ==UserScript==
// @name Twitter HQ images
// @namespace https://gist.github.com/RoxasShadow/031eda7f62d09bc8d61d1d5739038329
// @description Replace all the images with their HQ version
// @include https://twitter.com/*
// @author Roxas Shadow
// @version 1
// @grant none
// @run-at document-idle
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require https://raw.githubusercontent.com/cowboy/jquery-throttle-debounce/master/jquery.ba-throttle-debounce.min.js
// ==/UserScript==
(function() {
let hq = function() {
$('.js-adaptive-photo > img').each(function(i) {
let $e = $(this);
let url = $e.attr('src');
if(!url.endsWith(':orig')) {
$e.attr('src', url + ':orig');
}
});
};
hq();
$("#timeline").bind("DOMSubtreeModified", $.debounce(500, hq));
})();
/*
$('#global-actions').append(`
<li>
<a role="button" href="#" class="js-tooltip js-dynamic-tooltip" id="hqify" data-placement="bottom" data-original-title="">
<span class="Icon Icon--search Icon--large"></span>
<span class="text">HQ</span>
</a>
</li>`);
$('#hqify').on('click', (evt) => {
evt.preventDefault();
$('img[data-aria-label-part]').each((_, e) => {
let src = $(e).attr('src');
if(!src.endsWith(':orig')) {
$(e).attr('src', src + ':orig');
}
});
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment