-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackground.js
More file actions
26 lines (24 loc) · 882 Bytes
/
Copy pathbackground.js
File metadata and controls
26 lines (24 loc) · 882 Bytes
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
async function OpenGithubIssue(activeTab) {
const [result] = await chrome.scripting.executeScript({
target: {
tabId: activeTab.id,
},
func: () => {
const title = document.querySelector(".fancy-title").textContent.trim();
const body = document.querySelector("#post_1 .cooked").textContent;
return {
title, body
};
}
});
let { title, body } = result.result;
body = '> ' + body.replaceAll("\n", "\n> ") + `\n\nOriginally reported on ${activeTab.url}`;
chrome.tabs.create(
{
url: `https://github.com/ankitects/anki/issues/new?template=bug-report.md&title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`,
active: true,
});
}
chrome.action.onClicked.addListener((tab) => {
OpenGithubIssue(tab);
});