-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
45 lines (43 loc) · 1.45 KB
/
Copy pathcontent.js
File metadata and controls
45 lines (43 loc) · 1.45 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
function expandAllComments() {
for (let link of document.getElementsByClassName("TaskStoryFeed-expandLink")) {
if (link.innerHTML != "Hide Earlier Comments") {
link.click();
}
};
const interval = setInterval(function () {
for (let comment of document.getElementsByClassName("TruncatedRichText-expand")) {
comment.click();
};
if (document.getElementsByClassName("TruncatedRichText-expand").length == 0) {
clearInterval(interval);
}
}, 100);
}
// https://stackoverflow.com/questions/38881301/observe-mutations-on-a-target-node-that-doesnt-exist-yet
function waitForAddedNode(params) {
new MutationObserver(function(mutations) {
var el = document.querySelector(params.selector);
if (el) {
this.disconnect();
params.done(el);
}
}).observe(document, {
subtree: !!params.recursive,
childList: true,
});
}
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
console.log('message = ' + request.message);
if (request.message === "initializeExpandAction") {
waitForAddedNode({
selector: '.SingleTaskPaneSpreadsheet',
recursive: true,
done: function(el) {
console.log("Expanding Comments!");
expandAllComments();
}
});
}
}
);