Skip to content

Instantly share code, notes, and snippets.

@kazad
Created September 5, 2012 02:00
Show Gist options
  • Save kazad/3629119 to your computer and use it in GitHub Desktop.
Save kazad/3629119 to your computer and use it in GitHub Desktop.
Github / MindTouch integration
// ==UserScript==
// @name MindTouch/Github integration
// @version 1.0
// @namespace http://mindtouch.com/github
// @description Make github better for MindTouch employees
// @include https://github.com/*/Deki*
// loading code from from http://userscripts.org/scripts/review/123588
function main($) {
'use strict';
jQuery.noConflict();
// add custom CSS
var style = "a.fancybox {color: #4183C4 !important;} .fancybox-iframe { display: block; width: 100%; height: 100%;} .fancybox-wrap {z-index: 99;} .fancybox-inner {border: 4px solid #333; border-radius: 5px;}";
$("<style type='text/css'>" + style + "</style>").appendTo($("head"));
function applyYouTrack($el){
var newhtml = $el.html().replace(/([a-zA-Z]+[-]\d+)/g, '<a class="fancybox" href="http://youtrack.developer.mindtouch.com/issue/$1">$1</a>');
$el.html(newhtml);
}
$('h2.content-title,a.message,p.commit-title:not(:has(a.message))').each(function(i, el){
applyYouTrack($(el));
$('.fancybox').fancybox({
type: 'iframe',
width : 1000,
height : 600,
autoSize : true
});
});
}
function thirdParty($) {
'use strict';
jQuery.noConflict();
jQuery.extend({
// If you have any non-jQuery functions, they need to be wrapped in here.
});
// Put third-party jQuery plugins, extensions, etc. here
}
!function loader(i) {
var script
, requires = [ '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'
, '//cdnjs.cloudflare.com/ajax/libs/fancybox/2.0.4/jquery.fancybox.pack.js'
]
, head = document.getElementsByTagName('head')[0]
, makeScript = function () {
script = document.createElement('script');
script.type = 'text/javascript';
}
, loadLocal = function (fn) {
makeScript();
script.textContent = '(' + fn.toString() + ')(jQuery);';
head.appendChild(script);
}
;
(function (i) {
makeScript();
script.src = requires[i];
script.addEventListener('load', function () {
++i !== requires.length ? loader(i) : (loadLocal(thirdParty), loadLocal(main));
}, true);
head.appendChild(script);
})(i || 0);
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment