This repository was archived by the owner on Mar 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
45 lines (39 loc) · 1.29 KB
/
Copy pathapp.js
File metadata and controls
45 lines (39 loc) · 1.29 KB
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
var addLinks = function() {
var threadSubject = document.getElementsByClassName("hP")[0].innerHTML;
var openMessages = document.getElementsByClassName("h7");
Array.prototype.forEach.call(openMessages, function(message){
if(!message.querySelector(".pw-issue-add")){
var recipients = Array.prototype.map.call(
message.querySelector(".hb").children,
function(elem) {
return elem.attributes.email.value;
}
).concat(message.querySelector(".gD").attributes.email.value);
message.
querySelector("td.ady").
insertAdjacentHTML("beforeend", link(recipients, threadSubject));
}
})
}
var link = function(recipients, threadSubject){
return(
"<a " +
"class='pw-issue-add' " +
`href='${url(recipients, threadSubject)}' ` +
"target='_blank' " +
"style='margin-right: 20px; float: right;'>" +
"New Pathways Issue" +
"</a>"
);
};
var url = function(recipients, threadSubject) {
return(
"https://pathwaysbc.ca/issues/new?" +
`threadSubscribers=${encodeURIComponent(recipients.join(";"))}&` +
`threadSubject=${encodeURIComponent(threadSubject)}`
);
};
window.addEventListener("load", function() {
setTimeout(addLinks, 500);
document.addEventListener("click", function() { setTimeout(addLinks, 500)})
})