mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
Add :issue
excmd and autocmd to autofill new issues
This commit is contained in:
parent
331233b32e
commit
52103a0578
4 changed files with 43 additions and 1 deletions
|
@ -5,6 +5,7 @@ manversion=$(grep '"version":' ./src/manifest.json | cut -d":" -f2 | tr -d \" |
|
|||
version=$manversion-$gitversion
|
||||
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/background.js
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/content.js
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/static/newtab.html
|
||||
rm ./build/background.js.bak
|
||||
rm ./build/static/newtab.html.bak
|
||||
|
|
|
@ -4083,6 +4083,44 @@ export async function jsb(...str: string[]) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new tab the url of which is "https://github.com/tridactyl/tridactyl/issues/new" and automatically fill add tridactyl, firefox and os version to the issue.
|
||||
*/
|
||||
//#content
|
||||
export async function issue() {
|
||||
const newIssueUrl = "https://github.com/tridactyl/tridactyl/issues/new"
|
||||
if (window.location.href !== newIssueUrl) {
|
||||
return Messaging.message("controller_background", "acceptExCmd", ["tabopen " + newIssueUrl])
|
||||
}
|
||||
const textarea = document.getElementById("issue_body")
|
||||
if (!(textarea instanceof HTMLTextAreaElement)) {
|
||||
logger.warning("issue(): Couldn't find textarea element in github issue page.")
|
||||
return
|
||||
}
|
||||
let template = await (fetch(browser.extension.getURL("issue_template.md"))
|
||||
.then(resp => resp.body.getReader())
|
||||
.then(reader => reader.read())
|
||||
.then(r => (new TextDecoder("utf-8")).decode(r.value)))
|
||||
if (textarea.value !== template) {
|
||||
logger.debug("issue(): Textarea value differs from template, exiting early.")
|
||||
return
|
||||
}
|
||||
const platform = await browserBg.runtime.getPlatformInfo();
|
||||
// Remove the bit asking the user
|
||||
template = template.replace("* Operating system:\n", "")
|
||||
// Add this piece of information to the top of the template
|
||||
template = `Operating system: ${platform.os}\n` + template
|
||||
|
||||
const info = await browserBg.runtime.getBrowserInfo()
|
||||
template = template.replace("* Firefox version (Top right menu > Help > About Firefox):\n\n", "")
|
||||
template = `Firefox version: ${info.vendor} ${info.name} ${info.version}\n` + template
|
||||
|
||||
template = template.replace("* Tridactyl version (`:version`):\n\n", "")
|
||||
template = `Tridactyl version: ${TRI_VERSION}\n` + template
|
||||
|
||||
textarea.value = template
|
||||
}
|
||||
|
||||
//#background_helper
|
||||
import * as Parser from "rss-parser"
|
||||
import * as semverCompare from "semver-compare"
|
||||
|
|
|
@ -322,7 +322,9 @@ class default_config {
|
|||
*
|
||||
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
|
||||
*/
|
||||
DocLoad: {},
|
||||
DocLoad: {
|
||||
"https://github.com/tridactyl/tridactyl/issues/new": "issue"
|
||||
},
|
||||
|
||||
/**
|
||||
* Commands that will be run when pages are unloaded.
|
||||
|
|
|
@ -56,6 +56,7 @@ module.exports = {
|
|||
ignore: ["*.psd", "*1024px.png"],
|
||||
},
|
||||
{ from: "generated/static", to: "static" },
|
||||
{ from: "issue_template.md" },
|
||||
]),
|
||||
],
|
||||
// Fix css
|
||||
|
|
Loading…
Add table
Reference in a new issue