Last active
September 15, 2017 11:23
-
-
Save omgmog/374ed03fe8a77a6c4fee864e3ee5c664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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