Created
August 18, 2016 21:33
-
-
Save bcjordan/c2378d25ce807e860e57049f4b508c90 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Eyes link converter. | |
// @namespace https://code.org | |
// @version 0.1 | |
// @description Converts eyes result URLs to links and opens in new tabs. | |
// @match https://cucumber-logs.s3.amazonaws.com/* | |
// @copyright 2016 | |
// @require http://code.jquery.com/jquery-2.1.1.min.js | |
// ==/UserScript== | |
// To install: | |
// 1. Install TamperMonkey https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo | |
// 2. Click "Raw" above. | |
function urlify(text) { | |
var urlRegex = /(https?:\/\/eyes.[^\s]+)/g; | |
return text.replace(urlRegex, function(url) { | |
window.open(url, "_blank"); | |
return '<a href="' + url + '">' + url + '</a>'; | |
}); | |
} | |
$(document).on("ready", function() { | |
$('body').html(urlify($('body').html())); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment