This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcentral-links.user.js
58 lines (46 loc) · 1.77 KB
/
central-links.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ==UserScript==
// @name Anchor tags in Central
// @namespace https://central.tri.be/
// @version 0.1.1
// @description Adds anchor tags to some links in central
// @author Gustavo Bordoni
// @include /^https:\/\/central.tri.be(\/.*)?/
// @require http://soapbox.github.io/linkifyjs/js/linkify/linkify.min.js
// @require http://soapbox.github.io/linkifyjs/js/linkify/linkify-jquery.min.js
// @grant none
// ==/UserScript==
var central_links = {};
( function( $, my ) {
my.init = function() {
my.build_styles();
var regExpGoogleDocs = /docs\.google\.com.+\/d\/([^\/]+)/ig;
my.$headings = $( 'table.attributes' ).find( 'th:contains(Pull Request:), th:contains(Forum Threads:), th:contains(User Story:), th:contains(UserVoice Threads:)' );
my.$headings.each( function() {
var $this = $( this );
var $link_cell = $this.next( 'td' );
$link_cell.linkify({
target: "_blank",
format: function( value, type ) {
var matches = regExpGoogleDocs.exec( value );
if ( ! matches ){
return value;
}
return 'Google#' + matches[1];
}
});
$link_cell.find( 'a' ).append( '<br>' );
} );
};
my.build_styles = function() {
$( 'head' ).append( '<style id="tribe-anchor-tags-styles"/>' );
my.$styles = $( document.getElementById( 'tribe-anchor-tags-styles' ) );
my.$styles.html( [
'.attachments .files a {',
'display: inline-block;',
'}',
'' ].join( "\n" ) );
};
$( function() {
my.init();
});
} )( jQuery, central_links );