forked from comod/PhpStormRESTControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserScriptForBrowser.js
54 lines (41 loc) · 1.16 KB
/
userScriptForBrowser.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
// ==UserScript==
// @name PhpStormRESTControl
// @version 0.1
// @description Opens a file from Bitbucket in your IDE!
// @author Michael Wölk
// @match https://bitbucket.org/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/latest/jquery.js
// ==/UserScript==
(function () {
let msInitOnReady = 200;
let port = 8100;
function send(file = '', line = 0) {
let url = 'http://localhost:' + port + '/?' + file;
return $.ajax({
url,
type: "GET",
port
});
}
function init() {
$('[data-path]').each(function (i, sel) {
$(sel).find('.filename').prepend('<span class="phpstormIcon" style="cursor: pointer;"><img src="http://woelk.it/phpstorm_logo.jpg" height="16"/></span>');
});
$('.phpstormIcon').click(function () {
let filename = $(this).closest('section').data('path');
send(filename);
});
}
function initOnReady() {
setTimeout(function tick() {
if ($('[data-path]').length > 0) {
init();
} else {
setTimeout(tick, msInitOnReady);
}
}, msInitOnReady);
}
$(document).ready(function () {
initOnReady();
});
})();