Skip to content

Instantly share code, notes, and snippets.

@omgmog
Last active September 15, 2017 11:23
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 omgmog/374ed03fe8a77a6c4fee864e3ee5c664 to your computer and use it in GitHub Desktop.
Save omgmog/374ed03fe8a77a6c4fee864e3ee5c664 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Close and open url
// @namespace https://omgmog.net
// @version 0.1
// @description close issue and open first link from issue
// @author Max Glenister
// @match https://github.com/omgmog/meta-ifttt-reading-list/issues/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.querySelector('html').addEventListener('keydown', function(e) {
if (e.which === 88 && e.target.nodeName !== 'INPUT' && e.target.nodeName !== 'TEXTAREA') {
var url = window.location.href.match(/(https:\/\/github\.com\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-]+)\/issues\/\d+/);
if (url) {
// we're on an issue page
var button = document.querySelector('.js-comment-and-button');
button.click();
if (e.shiftKey) {
window.open(document.querySelector('.js-comment-body a:first-of-type').href);
}
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment