-
Notifications
You must be signed in to change notification settings - Fork 23
/
AboutConfigMultipleSelection.uc.js
82 lines (74 loc) · 2.78 KB
/
AboutConfigMultipleSelection.uc.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// ==UserScript==
// @name About:config Multiple Selection
// @version 0.3
// @description Allow multiple selection on about:config and more
// @namespace https://github.com/nightson/
// @author NightsoN
// @include chrome://browser/content/browser.xul
// @note 0.3 add "Copy as Function" to the contextmenu. Now you can copy config entries in user_pref(xxx, xxx); format to be used in user.js
// ==/UserScript==
window.addEventListener('DOMContentLoaded', function (event) {
var doc = event.target,
win;
if (!doc || !doc.location.href.startsWith('about:config')) return;
doc.getElementById('configTree').setAttribute('seltype', 'multiple');
win = doc.defaultView;
var contextMenu = doc.getElementById('configContext'),
menuitem = contextMenu.insertBefore(doc.createElement('menuitem'), doc.getElementById('copyValue').nextSibling);
menuitem.id = 'copyAsFunction';
menuitem.setAttribute('label', 'Copy as Function');
menuitem.setAttribute('accesskey', 'F');
menuitem.setAttribute('oncommand', 'copyAsFunction();');
win.getSelected = function () {
var arr = [],
i = 0,
k = 0,
j = win.view.selection.getRangeCount(),
start = {},
end = {};
for (i; i < j; i++) {
win.view.selection.getRangeAt(i, start, end);
for (k = start.value; k <= end.value; k++) {
arr.push(win.gPrefView[k]);
}
}
return arr;
}
win.ResetSelected = function () {
win.getSelected().forEach(function (i) {
win.gPrefBranch.clearUserPref(i.prefCol);
})
}
win.copyPref = function () {
var arr = [];
win.getSelected().forEach(function (i) {
arr.push(i.prefCol + ';' + i.valueCol);
});
win.gClipboardHelper.copyString(arr.join('\n'), document);
}
win.copyName = function () {
var arr = [];
win.getSelected().forEach(function (i) {
arr.push(i.prefCol);
});
win.gClipboardHelper.copyString(arr.join('\n'), document);
}
win.copyValue = function () {
var arr = [];
win.getSelected().forEach(function (i) {
arr.push(i.valueCol);
});
win.gClipboardHelper.copyString(arr.join('\n'), document);
}
win.copyAsFunction = function () {
var arr = [];
win.getSelected().forEach(function (i) {
if (i.typeCol === 32) {
arr.push('user_pref("' + i.prefCol + '", "' + i.valueCol + '");');
} else {
arr.push('user_pref("' + i.prefCol + '", ' + i.valueCol + ');');
}
});
win.gClipboardHelper.copyString(arr.join('\n'), document);
}
}, true);