Skip to content

Instantly share code, notes, and snippets.

@alex-kinokon
Last active November 27, 2015 02:45
Show Gist options
  • Save alex-kinokon/bc3b2fd90c08cb96e55b to your computer and use it in GitHub Desktop.
Save alex-kinokon/bc3b2fd90c08cb96e55b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name GitHub Instant
// @description Preloads GitHub content on link hover. CC0 Public Domain.
// @version 1.0
// @author Alex Mattrick
// @match https://github.com/*
// @match https://gist.github.com/*
// @icon https://assets-cdn.github.com/favicon.ico
// @require https://cdnjs.cloudflare.com/ajax/libs/instantclick/3.0.1/instantclick.min.js
// @grant none
// @grant GM_addStyle
// ==/UserScript==
function cleanup(body) {
var jQ = $(body);
jQ.find('.header, script, .btn-danger, .dangerzone, .file-navigation-option').attr('data-no-instant', '');
jQ.find('a.header-logo-invertocat, ul.header-nav.left, .header a.dropdown-item').attr('data-instant', '');
}
cleanup(document.body);
GM_addStyle('#instantclick { display: none; }');
InstantClick.init();
InstantClick.on('receive', function (url, body, title) {
cleanup(body);
return { body: body };
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment