-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (39 loc) · 1.4 KB
/
index.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
chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
if (changeInfo.status === "complete") {
const checkAndExecute = (url) => {
if (url.includes("github.com") && url.includes("issues")) {
console.log('Project page detected');
chrome.scripting.executeScript({
target: { tabId: tabId },
function: clickButton
});
}
};
checkAndExecute(tab.url);
}
});
function clickButton() {
activateMoreButton();
function activateMoreButton() {
console.log('Running script');
const buttons = document.querySelectorAll('.Link--primary.btn-link');
for (const button of buttons) {
if (button.textContent.trim() === '+1 more') {
button.click();
console.log('Button clicked:', button);
const events = ['click', 'mousedown', 'mouseup', 'focus'];
for (const eventType of events) {
const event = new MouseEvent(eventType, {
bubbles: true,
cancelable: true,
view: window
});
button.dispatchEvent(event);
}
}
}
}
window.navigation.addEventListener("navigate", (event) => {
activateMoreButton();
});
}