-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathREADME
More file actions
327 lines (269 loc) · 14.6 KB
/
Copy pathREADME
File metadata and controls
327 lines (269 loc) · 14.6 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
スクリプトファイルの探し方:
https://github.com/alice0775/userChrome.js を開いて[Go to file]をクリック, 左のテキスト入力欄に探したいスクリプトのファイル名を入力, リスト内の該当するものをクリック
ディレクトリ番号が大きいものほど新しく/更新されたスクリプト
FirefoxのバージョンNoより大きいディレクトリ番号内のスクリプトはそのバージョンでは動かない
FirefoxのバージョンNoより小さいディレクトリ番号内のスクリプトは動くかも知れない
スクリプトの保存方法:
スクリプト名をクリック、[RAW]ボタンをクリック、名前を付けて保存
ファイルはUTF-8のBOMなしで保存
==================
userchrome.jsのインストール方法 方法 その1:
1. アプリケーションインストールフォルダ(例えば, %ProgramFiles%\Mozilla Firefox)直下に以下のファイルを保存する
117/install_folder/config.js
2. アプリケーションインストールフォルダ\defaults\pref 直下に以下のファイルを保存する
117/install_folder\defaults\pref\config-prefs.js
3. プロファイルフォルダ(例えば, %APPDATA%\Mozilla\Firefox\Profiles\hogehoge.default)直下に chrome フォルダを作り以下のファイルを保存する
141/userChrome.js, 139/userChrome.js, 135/userChrome.js または 106/userChrome.js
必要に応じて 72/userChrome.css
4. 必要なスクリプトファイルを保存する
5. 念のため 一回 %ProgramFiles%\Mozilla Firefox\firefox.exe -purgecaches オプション付きで起動する
==================
userchrome.jsのインストール方法 方法 その2(https://github.com/xiaoxiaoflood/firefox-scripts):
136以上はhttps://github.com/xiaoxiaoflood/firefox-scripts/issues/343も参照
最近は更新されてないので削除
==================
userchrome.jsのインストール方法 方法 その3(https://bitbucket.org/BSTweaker/userchromejs/src/master/loader/):
1. config.jsが動くようにしておく (例えば その1の1. 2. )
2. https://bitbucket.org/BSTweaker/userchromejs/src/master/loader/
上記に従いconfig.jsコードを修正
3. chromeフォルダに以下のファイルを保存
https://bitbucket.org/BSTweaker/userchromejs/src/master/loader/UserChromeJSLoader.mjs
4. 必要に応じ、スクリプトの読み込み順番(大小文字を区別しない)に並び変えるため, およびスクリプトの有効無効を中クリックで行えるようにしかつメニューを閉じないように
--- org/UserChromeJSLoader.mjs 2025-05-20 13:28:55.155740200 +0900
+++ UserChromeJSLoader.mjs 2025-05-20 13:29:15.960386900 +0900
@@ -1,17 +1,18 @@
const ucjsLoaderConfig = {
/* chrome以下にある.uc.jsが置いてあるフォルダを列挙する "."はchromeフォルダ直下を指す */
subScriptFolders : [".", "SubScript"],
/* trueにするとスクリプトをファイル名の辞書順で読み込む */
loadScriptsInOrder : true,
+ loadScriptsInOrderIgnoreCase : true,
/* chrome直下に保存される設定ファイル名 */
configFileName : "UserChromeJSLoader.config.json",
/* スクリプトの編集 (メニュー右クリック) に使うエディタのパス */
editorPath : "",
};
const mainChromeWindowURL = "chrome://browser/content/browser.xhtml";
const chromeDir = PathUtils.join(PathUtils.profileDir, "chrome");
const baseResourceURI = Components.stack.filename.slice(0, Components.stack.filename.lastIndexOf("/"));
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
setTimeout: "resource://gre/modules/Timer.sys.mjs",
@@ -186,19 +187,25 @@
this.scriptDirs = dirs;
this.scripts = [];
this.disabledScripts = null;
this.groupedScripts = new Map();
this.config = new Config(PathUtils.join(chromeDir, ucjsLoaderConfig.configFileName));
this.isReady = this.load();
}
get sortedScripts() {
+ if (ucjsLoaderConfig.loadScriptsInOrderIgnoreCase) {
+ return this.scripts.sort((a, b) => {
+ return a.path.toLowerCase() > b.path.toLowerCase() ? 1 : -1;
+ });
+ } else {
return this.scripts.sort((a, b) => {
return a.path > b.path ? 1 : -1;
});
+ }
}
load() {
return new Promise(resolve => {
let newScripts = [];
let existingScripts = [];
let promises = [];
let start = Date.now();
for (let dir of this.scriptDirs) {
@@ -307,16 +314,28 @@
});
toolsMenu.querySelector("#UCJSLoader-sandboxed")?.addEventListener("command", event => {
let enabled = !!scriptLibrary.config.get("force_sandbox");
scriptLibrary.config.set("force_sandbox", !enabled);
});
toolsMenu.querySelector("#UCJSLoader-open-folder")?.addEventListener("command", event => {
Services.dirsvc.get("UChrm", Ci.nsIFile).launch();
});
+ win.document.getElementById("UCJSLoader-menu").addEventListener("mouseup", event => {
+ const menuitem = event.target;
+ if (event.button == 1)
+ {
+ menuitem.setAttribute('closemenu', 'none');
+ menuitem.parentNode.addEventListener('popuphidden', () => {
+ menuitem.removeAttribute('closemenu');
+ }, { once: true });
+ if (event.ctrlKey)
+ menuitem.parentNode.hidePopup();
+ }
+ });
toolsMenu.addEventListener("popupshowing", event => {
if (event.target !== toolsMenu) return;
let parentMenu = win.document.getElementById("UCJSLoader-menu");
let target = parentMenu.querySelector("#UCJSLoader-submenu-0");
while (target) {
let tmp = target.nextElementSibling;
target.remove();
target = tmp;
@@ -332,17 +351,17 @@
let submenu = parentMenu.querySelector(`#UCJSLoader-submenu-${n++} menupopup`);
for (let script of value) {
let item = win.document.createXULElement("menuitem");
item.setAttribute("label", script.filename);
item.setAttribute("type", "checkbox");
item.setAttribute("checked", !script.disabled);
let callback = event => {
/* only command event is fired for right-click on macOS */
- if (event.type === "command" && event.button === 0) script.disabled = !script.disabled;
+ if (event.type === "command" && event.button <= 1) script.disabled = !script.disabled;
else if (event.button === 2) script.edit();
};
item.addEventListener("command", callback, {once: true});
item.addEventListener("click", callback, {once: true});
submenu.appendChild(item);
}
}
toolsMenu.querySelector("#UCJSLoader-enabled")?.setAttribute("checked", !scriptLibrary.config.get("disabled"));
@@ -353,19 +372,22 @@
}
getSandboxFor(win) {
let sb = new Cu.Sandbox(win, {
sandboxPrototype: win,
sameZoneAs: win,
});
/* toSource() is not available in sandbox */
Cu.evalInSandbox(`
- Object.defineProperty(Function.prototype, "toSource", {value: window.Function.prototype.toSource});
- Object.defineProperty(Object.prototype, "toSource", {value: window.Object.prototype.toSource});
- Object.defineProperty(Array.prototype, "toSource", {value: window.Array.prototype.toSource});
+ Function.prototype.toSource = window.Function.prototype.toSource;
+ Object.defineProperty(Function.prototype, "toSource", {enumerable : false})
+ Object.prototype.toSource = window.Object.prototype.toSource;
+ Object.defineProperty(Object.prototype, "toSource", {enumerable : false})
+ Array.prototype.toSource = window.Array.prototype.toSource;
+ Object.defineProperty(Array.prototype, "toSource", {enumerable : false})
`, sb);
win.addEventListener("unload", () => {
lazy.setTimeout(() => {
Cu.nukeSandbox(sb);
}, 0);
}, {once: true});
return sb;
}
5. 必要なスクリプトファイルを保存する
6. 念のため 一回 %ProgramFiles%\Mozilla Firefox\firefox.exe -purgecaches オプション付きで起動する
==================
userchrome.jsのインストール方法 方法 その4(https://github.com/onemen/TabMixPlus/tree/main?tab=readme-ov-file):
1. アプリケーションインストールフォルダ(例えば, %ProgramFiles%\Mozilla Firefox)直下に以下のファイルを解凍保存する
https://github.com/onemen/TabMixPlus/releases/download/dev-build/fx-folder.zip
2, プロファイルフォルダ(例えば, %APPDATA%\Mozilla\Firefox\Profiles\hogehoge.default)直下に chrome フォルダを作り以下のファイルをダウンロードし解凍保存する
https://github.com/onemen/TabMixPlus/releases/download/dev-build/utils.zip
3. Firefoxのsandbox対応と初期化中にスクリプトが実行されないように及び日本語ファイル名対応にするため,展開保存した utils\userChrome.js を修正
--- org/userChrome.js 2025-11-30 05:51:26.000000000 +0900
+++ userChrome.js 2026-01-10 14:11:25.704357600 +0900
@@ -1,14 +1,15 @@
'use strict';
ChromeUtils.defineESModuleGetters(this, {
xPref: 'chrome://userchromejs/content/xPref.sys.mjs',
Management: 'resource://gre/modules/Extension.sys.mjs',
AppConstants: 'resource://gre/modules/AppConstants.sys.mjs',
+ setTimeout: "resource://gre/modules/Timer.sys.mjs",
});
let UC = {
webExts: new Map(),
sidebar: new Map(),
sandboxes: new WeakMap()
};
@@ -54,17 +55,21 @@
let def = ['', ''];
let author = (header.match(/\/\/ @author\s+(.+)\s*$/im) || def)[1];
let filename = aFile.leafName || '';
return this.scripts[filename] = {
filename: filename,
file: aFile,
- url: Services.io.getProtocolHandler('file').QueryInterface(Ci.nsIFileProtocolHandler).getURLSpecFromDir(this.chromedir) + filename,
+ url:
+ Services.io
+ .getProtocolHandler('file')
+ .QueryInterface(Ci.nsIFileProtocolHandler)
+ .getURLSpecFromActualFile(aFile) /*.getURLSpecFromDir(this.chromedir) + filename*/ ,
name: (header.match(/\/\/ @name\s+(.+)\s*$/im) || def)[1],
description: (header.match(/\/\/ @description\s+(.+)\s*$/im) || def)[1],
version: (header.match(/\/\/ @version\s+(.+)\s*$/im) || def)[1],
author: (header.match(/\/\/ @author\s+(.+)\s*$/im) || def)[1],
regex: new RegExp('^' + exclude + '(' + (rex.include.join('|') || '.*') + ')$', 'i'),
id: (header.match(/\/\/ @id\s+(.+)\s*$/im) || ['', filename.split('.uc.js')[0] + '@' + (author || 'userChromeJS')])[1],
homepageURL: (header.match(/\/\/ @homepageURL\s+(.+)\s*$/im) || def)[1],
downloadURL: (header.match(/\/\/ @downloadURL\s+(.+)\s*$/im) || def)[1],
@@ -107,18 +112,20 @@
if (script.onlyonce && script.isRunning) {
if (script.startup) {
Cu.evalInSandbox(`(function(script, win){${script.startup}})`, this.getSandbox(win))(script, win);
}
return;
}
try {
- Services.scriptloader.loadSubScript(script.url + '?' + script.file.lastModifiedTime,
- script.onlyonce ? { window: win } : win);
+ let timer = setTimeout(() => {
+ Services.scriptloader.loadSubScript(script.url + '?' + script.file.lastModifiedTime,
+ script.onlyonce ? { window: win } : win);
+ }, 0);
script.isRunning = true;
if (script.startup) {
Cu.evalInSandbox(`(function(script, win){${script.startup}})`, this.getSandbox(win))(script, win);
}
if (!script.shutdown) {
this.everLoaded.push(script.id);
}
} catch (ex) {
@@ -190,20 +197,20 @@
xPref.set(_uc.PREF_SCRIPTSDISABLED, '', true);
}
let UserChrome_js = {
observe: function (aSubject) {
if (aSubject.document.isUncommittedInitialDocument) {
const parent = aSubject.parent;
aSubject.addEventListener("DOMContentLoaded", () => {
- parent.addEventListener("DOMContentLoaded", this, {once: true, capture: true})
+ parent.addEventListener("load", this, {once: true, capture: true})
}, {once:true})
} else {
- aSubject.addEventListener('DOMContentLoaded', this, {once: true, capture: true});
+ aSubject.addEventListener('load', this, {once: true, capture: true});
}
},
handleEvent: function (aEvent) {
let document = aEvent.target;
let window = document.defaultView;
this.load(window);
},
@@ -255,10 +262,10 @@
_uc.chromedir.append(_uc.scriptsDir);
_uc.getScripts();
let windows = Services.wm.getEnumerator(null);
while (windows.hasMoreElements()) {
let win = windows.getNext();
if (!('UC' in win))
UserChrome_js.load(win)
}
- Services.obs.addObserver(UserChrome_js, 'domwindowopened', false);
+ Services.obs.addObserver(UserChrome_js, 'chrome-document-global-created', false);
}
4. 必要なスクリプトファイルを保存する
5. https://raw.githubusercontent.com/xiaoxiaoflood/firefox-scripts/master/chrome/rebuild_userChrome.uc.js を使う場合は、必要に応じ、日本語スクリプト名に対応するため,
editorArgs.push(script.file.path);
を
editorArgs.push(Services.io.newURI(script.url)
.QueryInterface(Ci.nsIFileURL).file.path);
に、さらに
process.run(
を
process.runw(
に置き換える
※ Nightlyでは、security.browser_xhtml_csp.enabled を falseにする。(もしくは、セキュリティを気にする場合はすべての'onほにゃらら'をイベントリスナーに変更する必要がある)
6. 念のため 一回 %ProgramFiles%\Mozilla Firefox\firefox.exe -purgecaches オプション付きで起動する
* 「必要に応じ」はやらなくてもいいよ
DeepL.com(無料版)で翻訳しました。
免責事項
一切の責任を負いません。
自己の責任の上で使用して下さい。