mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Add removepref excmd
This commit is contained in:
parent
fd7f7f218a
commit
647d3221a9
2 changed files with 26 additions and 1 deletions
|
@ -491,13 +491,23 @@ export async function colourscheme(themename: string) {
|
|||
* Note that not all of the keys Firefox uses are suggested by Tridactyl.
|
||||
*
|
||||
* e.g.: `setpref general.warnOnAboutConfig false`
|
||||
* `setpref extensions.webextensions.restricterDomains ""`
|
||||
*/
|
||||
//#background
|
||||
export function setpref(key: string, ...value: string[]) {
|
||||
return Native.writePref(key, value.join(" "))
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a setting from your user.js file.
|
||||
*
|
||||
* @param key The key that should be set. Must not be quoted. Must not contain spaces.
|
||||
*
|
||||
*/
|
||||
//#background
|
||||
export function removepref(key: string) {
|
||||
return Native.removePref(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Like [[fixamo]] but quieter.
|
||||
*
|
||||
|
|
|
@ -758,6 +758,21 @@ export async function writePref(name: string, value: any) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Removes a preference from user.js */
|
||||
export async function removePref(name: string) {
|
||||
const file = (await getProfileDir()) + "/user.js"
|
||||
// No need to check the return code because read returns "" when failing to
|
||||
// read a file
|
||||
const text = (await read(file)).content
|
||||
const prefPos = text.indexOf(`user_pref("${name}",`)
|
||||
if (prefPos >= 0) {
|
||||
let substr = text.substring(prefPos)
|
||||
const prefEnd = substr.indexOf(";\n") + 1
|
||||
substr = text.substring(prefPos, prefPos + prefEnd)
|
||||
write(file, text.replace(substr, ``))
|
||||
}
|
||||
}
|
||||
|
||||
/** Obey Mozilla's orders https://github.com/tridactyl/tridactyl/issues/1800 */
|
||||
export async function unfixamo() {
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue