-
Notifications
You must be signed in to change notification settings - Fork 5
/
edit-with-emacs.js
48 lines (36 loc) · 1.52 KB
/
edit-with-emacs.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
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/*/*/pull/*
// @grant none
// ==/UserScript==
function createLink(fileName, lineNumber) {
var project = document.URL.match(/github.com\/([^/]+\/[^/]+)/)[1];
return "org-protocol://github-lines://" + project + "/" + fileName + "/" + lineNumber;
}
(function() {
'use strict';
var forEach = Array.prototype.forEach;
var comments=document.querySelectorAll(".js-inline-comments-container");
comments.forEach(function(f) {
var file=f.previousElementSibling.previousElementSibling.firstElementChild.title;
var a = f.previousElementSibling.querySelectorAll("td.blob-num");
var line = a[a.length-1].getAttribute("data-line-number");
//var buttonera = f.querySelector("form.js-resolvable-timeline-thread-form");
// var buttonera = f.querySelector("div.js-line-comments");
var buttonera = f;
var bu=document.createElement("a");
bu.setAttribute("class", "btn m-3");
// bu.setAttribute("style", "float: left;");
bu.textContent = "Open in Emacs";
bu.setAttribute("href", createLink(file, line));
buttonera.appendChild(bu);
var form= f.querySelector("form.js-resolvable-timeline-thread-form")
form.setAttribute("style", "float: left;");
console.log(file , line);
});
// Your code here...
})();