SHOW:
|
|
- or go back to the newest paste.
1 | - | Common subdirectories: profexer/chrome and original/chrome |
1 | + | diff -rU3 original/chrome/content/useragentswitcher/options/dialogs/useragent.js profexer/chrome/content/useragentswitcher/options/dialogs/useragent.js |
2 | - | diff -U1 profexer/install.js original/install.js |
2 | + | --- original/chrome/content/useragentswitcher/options/dialogs/useragent.js 2011-01-04 18:53:34.000000000 +0200 |
3 | - | --- profexer/install.js 2012-06-16 00:23:16.000000000 +0300 |
3 | + | +++ profexer/chrome/content/useragentswitcher/options/dialogs/useragent.js 2012-06-16 00:25:20.000000000 +0300 |
4 | - | +++ original/install.js 2011-01-04 18:53:36.000000000 +0200 |
4 | + | @@ -9,20 +9,21 @@ |
5 | - | @@ -1,4 +1,4 @@ |
5 | + | window.opener.UserAgentSwitcherOptions.appVersion = null; |
6 | - | -var author = "Created by: Chris Pederick, Edited by: Profexer"; |
6 | + | window.opener.UserAgentSwitcherOptions.description = null; |
7 | - | +var author = "Chris Pederick"; |
7 | + | window.opener.UserAgentSwitcherOptions.platform = null; |
8 | + window.opener.UserAgentSwitcherOptions.oscpu = null; | |
9 | - | -var displayName = "User Agent Switcher (Profexer edition)"; |
9 | + | window.opener.UserAgentSwitcherOptions.userAgent = null; |
10 | - | +var displayName = "User Agent Switcher"; |
10 | + | }, |
11 | - | |
12 | - | @@ -70,2 +70,2 @@ |
12 | + | + |
13 | // Initializes the user agent dialog box | |
14 | initialize: function() | |
15 | { | |
16 | var type = window.arguments[0]; | |
17 | - | diff -U1 profexer/install.rdf original/install.rdf |
17 | + | - |
18 | - | --- profexer/install.rdf 2012-06-16 00:21:48.000000000 +0300 |
18 | + | + |
19 | - | +++ original/install.rdf 2011-01-04 18:53:36.000000000 +0200 |
19 | + | // If the type is new |
20 | - | @@ -6,12 +6,12 @@ |
20 | + | if(type == "new") |
21 | { | |
22 | - | - <!--<em:aboutURL>chrome://useragentswitcher/content/about/about.xul</em:aboutURL>--> |
22 | + | document.documentElement.getButton("accept").disabled = true; |
23 | - | - <em:creator>Created by: Chris Pederick, Edited by: Profexer</em:creator> |
23 | + | document.title = UserAgentSwitcherStringBundle.getString("newUserAgent"); |
24 | - | + <em:aboutURL>chrome://useragentswitcher/content/about/about.xul</em:aboutURL> |
24 | + | - |
25 | - | + <em:creator>Chris Pederick</em:creator> |
25 | + | + |
26 | this.retrieveDefault(); | |
27 | - | - <!--<em:homepageURL>http://chrispederick.com/work/user-agent-switcher/</em:homepageURL>--> |
27 | + | } |
28 | - | + <em:homepageURL>http://chrispederick.com/work/user-agent-switcher/</em:homepageURL> |
28 | + | else if(type == "edit") |
29 | @@ -34,13 +35,14 @@ | |
30 | document.getElementById("useragentswitcher-app-version").value = window.arguments[3]; | |
31 | - | - <em:name>User Agent Switcher (Profexer edition)</em:name> |
31 | + | document.getElementById("useragentswitcher-description").value = window.arguments[4]; |
32 | - | + <em:name>User Agent Switcher</em:name> |
32 | + | document.getElementById("useragentswitcher-platform").value = window.arguments[5]; |
33 | - document.getElementById("useragentswitcher-user-agent").value = window.arguments[6]; | |
34 | - | - <!--<em:updateInfoURL>http://chrispederick.com/work/user-agent-switcher/history/</em:updateInfoURL>--> |
34 | + | - document.getElementById("useragentswitcher-vendor").value = window.arguments[7]; |
35 | - | - <em:version>0.7.3 (PE)</em:version> |
35 | + | - document.getElementById("useragentswitcher-vendor-sub").value = window.arguments[8]; |
36 | - | + <em:updateInfoURL>http://chrispederick.com/work/user-agent-switcher/history/</em:updateInfoURL> |
36 | + | + document.getElementById("useragentswitcher-oscpu").value = window.arguments[6]; |
37 | - | + <em:version>0.7.3</em:version> |
37 | + | + document.getElementById("useragentswitcher-user-agent").value = window.arguments[7]; //6 |
38 | + document.getElementById("useragentswitcher-vendor").value = window.arguments[8]; //7 | |
39 | - | @@ -46,3 +46,3 @@ |
39 | + | + document.getElementById("useragentswitcher-vendor-sub").value = window.arguments[9]; //8 |
40 | document.title = UserAgentSwitcherStringBundle.getString("editUserAgent"); | |
41 | - | - <!--<em:id>songbird@songbirdnest.com</em:id>--> |
41 | + | } |
42 | - | + <em:id>songbird@songbirdnest.com</em:id> |
42 | + | }, |
43 | - | |
44 | - | @@ -52,2 +52,2 @@ |
44 | + | + |
45 | // Retrieves the default user agent | |
46 | retrieveDefault: function() | |
47 | { | |
48 | @@ -49,117 +51,135 @@ | |
49 | - | Only in profexer/: user_agent_switcher-0.7.3-fx+sm+profexer+edition.xpi |
49 | + | var appVersion = null; |
50 | var description = null; | |
51 | var platform = null; | |
52 | + var oscpu = null; | |
53 | var userAgent = null; | |
54 | var vendor = null; | |
55 | var vendorSub = null; | |
56 | - | |
57 | + | |
58 | // If the app code name is being overridden | |
59 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.appName")) | |
60 | { | |
61 | appCodeName = UserAgentSwitcherPreferences.getStringPreference("general.useragent.appName", true); | |
62 | - | |
63 | + | |
64 | UserAgentSwitcherPreferences.deletePreference("general.useragent.appName"); | |
65 | } | |
66 | - | |
67 | + | |
68 | // If the app name is being overridden | |
69 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.appname.override")) | |
70 | { | |
71 | appName = UserAgentSwitcherPreferences.getStringPreference("general.appname.override", true); | |
72 | - | |
73 | + | |
74 | UserAgentSwitcherPreferences.deletePreference("general.appname.override"); | |
75 | } | |
76 | - | |
77 | + | |
78 | // If the app version is being overridden | |
79 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.appversion.override")) | |
80 | { | |
81 | appVersion = UserAgentSwitcherPreferences.getStringPreference("general.appversion.override", true); | |
82 | - | |
83 | + | |
84 | UserAgentSwitcherPreferences.deletePreference("general.appversion.override"); | |
85 | } | |
86 | - | |
87 | + | |
88 | // If the platform is being overridden | |
89 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.platform.override")) | |
90 | { | |
91 | platform = UserAgentSwitcherPreferences.getStringPreference("general.platform.override", true); | |
92 | - | |
93 | + | |
94 | UserAgentSwitcherPreferences.deletePreference("general.platform.override"); | |
95 | } | |
96 | - | |
97 | + | |
98 | + // PROFEDIT: If the oscpu is being overridden | |
99 | + if(UserAgentSwitcherPreferences.isPreferenceSet("general.oscpu.override")) | |
100 | + { | |
101 | + oscpu = UserAgentSwitcherPreferences.getStringPreference("general.oscpu.override", true); | |
102 | + | |
103 | + UserAgentSwitcherPreferences.deletePreference("general.oscpu.override"); | |
104 | + } | |
105 | + // ENDPROFEDIT | |
106 | + | |
107 | // If the user agent is being overridden | |
108 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.override")) | |
109 | { | |
110 | userAgent = UserAgentSwitcherPreferences.getStringPreference("general.useragent.override", true); | |
111 | - | |
112 | + | |
113 | UserAgentSwitcherPreferences.deletePreference("general.useragent.override"); | |
114 | } | |
115 | - | |
116 | + | |
117 | // If the vendor is being overridden | |
118 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.vendor")) | |
119 | { | |
120 | vendor = UserAgentSwitcherPreferences.getStringPreference("general.useragent.vendor", true); | |
121 | - | |
122 | + | |
123 | UserAgentSwitcherPreferences.deletePreference("general.useragent.vendor"); | |
124 | } | |
125 | - | |
126 | + | |
127 | // If the vendor sub is being overridden | |
128 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.vendorSub")) | |
129 | { | |
130 | vendorSub = UserAgentSwitcherPreferences.getStringPreference("general.useragent.vendorSub", true); | |
131 | - | |
132 | + | |
133 | UserAgentSwitcherPreferences.deletePreference("general.useragent.vendorSub"); | |
134 | } | |
135 | - | |
136 | + | |
137 | document.getElementById("useragentswitcher-app-code-name").value = navigator.appCodeName; | |
138 | document.getElementById("useragentswitcher-app-name").value = navigator.appName; | |
139 | document.getElementById("useragentswitcher-app-version").value = navigator.appVersion; | |
140 | document.getElementById("useragentswitcher-platform").value = navigator.platform; | |
141 | + document.getElementById("useragentswitcher-oscpu").value = navigator.oscpu; | |
142 | document.getElementById("useragentswitcher-user-agent").value = navigator.userAgent; | |
143 | document.getElementById("useragentswitcher-vendor").value = navigator.vendor; | |
144 | document.getElementById("useragentswitcher-vendor-sub").value = navigator.vendorSub; | |
145 | - | |
146 | + | |
147 | // If the app code name was being overridden | |
148 | if(appCodeName) | |
149 | { | |
150 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.appName", appCodeName); | |
151 | } | |
152 | - | |
153 | + | |
154 | // If the app name was being overridden | |
155 | if(appName) | |
156 | { | |
157 | UserAgentSwitcherPreferences.setStringPreference("general.appname.override", appName); | |
158 | } | |
159 | - | |
160 | + | |
161 | // If the app version was being overridden | |
162 | if(appVersion) | |
163 | { | |
164 | UserAgentSwitcherPreferences.setStringPreference("general.appversion.override", appVersion); | |
165 | } | |
166 | - | |
167 | + | |
168 | // If the platform was being overridden | |
169 | if(platform) | |
170 | { | |
171 | UserAgentSwitcherPreferences.setStringPreference("general.platform.override", platform); | |
172 | } | |
173 | - | |
174 | + | |
175 | + // PROFEDIT: If the oscpu was being overridden | |
176 | + if(oscpu) | |
177 | + { | |
178 | + UserAgentSwitcherPreferences.setStringPreference("general.oscpu.override", oscpu); | |
179 | + } | |
180 | + // ENDPROFEDIT | |
181 | + | |
182 | // If the user agent was being overridden | |
183 | if(userAgent) | |
184 | { | |
185 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.override", userAgent); | |
186 | } | |
187 | - | |
188 | + | |
189 | // If the vendor was being overridden | |
190 | if(vendor) | |
191 | { | |
192 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.vendor", vendor); | |
193 | } | |
194 | - | |
195 | + | |
196 | // If the vendor sub was being overridden | |
197 | if(vendorSub) | |
198 | { | |
199 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.vendorSub", vendorSub); | |
200 | } | |
201 | }, | |
202 | - | |
203 | + | |
204 | // Saves a user agent | |
205 | saveUserAgent: function() | |
206 | { | |
207 | @@ -168,14 +188,15 @@ | |
208 | window.opener.UserAgentSwitcherOptions.appVersion = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-app-version").value); | |
209 | window.opener.UserAgentSwitcherOptions.description = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-description").value); | |
210 | window.opener.UserAgentSwitcherOptions.platform = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-platform").value); | |
211 | + window.opener.UserAgentSwitcherOptions.oscpu = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-oscpu").value); | |
212 | window.opener.UserAgentSwitcherOptions.userAgent = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-user-agent").value); | |
213 | window.opener.UserAgentSwitcherOptions.vendor = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-vendor").value); | |
214 | window.opener.UserAgentSwitcherOptions.vendorSub = UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-vendor-sub").value); | |
215 | }, | |
216 | - | |
217 | + | |
218 | // Disable the OK button if the description is not set | |
219 | updateDescription: function() | |
220 | { | |
221 | document.documentElement.getButton("accept").disabled = (UserAgentSwitcherString.trim(document.getElementById("useragentswitcher-description").value).length == 0); | |
222 | } | |
223 | -}; | |
224 | \ No newline at end of file | |
225 | +}; | |
226 | diff -rU3 original/chrome/content/useragentswitcher/options/dialogs/useragent.xul profexer/chrome/content/useragentswitcher/options/dialogs/useragent.xul | |
227 | --- original/chrome/content/useragentswitcher/options/dialogs/useragent.xul 2011-01-04 18:53:34.000000000 +0200 | |
228 | +++ profexer/chrome/content/useragentswitcher/options/dialogs/useragent.xul 2012-06-16 00:08:52.000000000 +0300 | |
229 | @@ -22,7 +22,7 @@ | |
230 | <vbox> | |
231 | <description id="useragentswitcher-new-user-agent">&useragentswitcher.new.user.agent.description;</description> | |
232 | <separator id="useragentswitcher-user-agent-separator"/> | |
233 | - | |
234 | + | |
235 | <grid flex="1"> | |
236 | <columns> | |
237 | <column/> | |
238 | @@ -54,6 +54,10 @@ | |
239 | <textbox id="useragentswitcher-platform"/> | |
240 | </row> | |
241 | <row align="center"> | |
242 | + <label control="useragentswitcher-oscpu" value="&useragentswitcher.oscpu;"/> | |
243 | + <textbox id="useragentswitcher-oscpu"/> | |
244 | + </row> | |
245 | + <row align="center"> | |
246 | <label control="useragentswitcher-vendor" value="&useragentswitcher.vendor;"/> | |
247 | <textbox id="useragentswitcher-vendor"/> | |
248 | </row> | |
249 | diff -rU3 original/chrome/content/useragentswitcher/options/options.js profexer/chrome/content/useragentswitcher/options/options.js | |
250 | --- original/chrome/content/useragentswitcher/options/options.js 2011-01-04 18:53:34.000000000 +0200 | |
251 | +++ profexer/chrome/content/useragentswitcher/options/options.js 2012-06-16 00:05:39.000000000 +0300 | |
252 | @@ -8,10 +8,11 @@ | |
253 | description: null, | |
254 | folder: null, | |
255 | platform: null, | |
256 | + oscpu: null, | |
257 | userAgent: null, | |
258 | vendor: null, | |
259 | vendorSub: null, | |
260 | - | |
261 | + | |
262 | // Adds a tree item to the selection | |
263 | addTreeItemToSelection: function(treeItem) | |
264 | { | |
265 | @@ -20,7 +21,7 @@ | |
266 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
267 | var selections = treeView.selection.getRangeCount(); | |
268 | var selectedItem = null; | |
269 | - | |
270 | + | |
271 | // If there are no selections | |
272 | if(selections == 0) | |
273 | { | |
274 | @@ -37,7 +38,7 @@ | |
275 | { | |
276 | treeView.selection.getRangeAt(selections - 1, startIndex, endIndex); | |
277 | } | |
278 | - | |
279 | + | |
280 | selectedItem = treeView.getItemAtIndex(endIndex.value); | |
281 | ||
282 | // If the selected item is set | |
283 | @@ -55,7 +56,7 @@ | |
284 | } | |
285 | } | |
286 | }, | |
287 | - | |
288 | + | |
289 | // Copies user agents | |
290 | copy: function() | |
291 | { | |
292 | @@ -63,14 +64,14 @@ | |
293 | var startIndex = {}; | |
294 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
295 | var selections = treeView.selection.getRangeCount(); | |
296 | - | |
297 | + | |
298 | this.clipboard = []; | |
299 | ||
300 | // If there is 1 selection | |
301 | if(selections == 1) | |
302 | - { | |
303 | + { | |
304 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
305 | - | |
306 | + | |
307 | // If more than one item is selected | |
308 | if(endIndex.value - startIndex.value > 0) | |
309 | { | |
310 | @@ -79,13 +80,13 @@ | |
311 | else | |
312 | { | |
313 | var selectedItem = treeView.getItemAtIndex(startIndex.value); | |
314 | - | |
315 | + | |
316 | // If an item is selected | |
317 | if(selectedItem) | |
318 | { | |
319 | this.clipboard.push(selectedItem.cloneNode(true)); | |
320 | } | |
321 | - } | |
322 | + } | |
323 | } | |
324 | else | |
325 | { | |
326 | @@ -98,20 +99,20 @@ | |
327 | } | |
328 | } | |
329 | }, | |
330 | - | |
331 | + | |
332 | // Copies selections | |
333 | copySelections: function(treeView, startIndex, endIndex) | |
334 | { | |
335 | var endValue = endIndex.value; | |
336 | var startValue = startIndex.value; | |
337 | - | |
338 | + | |
339 | // Loop through the items in reverse order to delete without changing the index | |
340 | for(var index = startValue; index <= endValue; index++) | |
341 | { | |
342 | this.clipboard.push(treeView.getItemAtIndex(index).cloneNode(true)); | |
343 | } | |
344 | }, | |
345 | - | |
346 | + | |
347 | // Cuts user agents | |
348 | cut: function() | |
349 | { | |
350 | @@ -119,14 +120,14 @@ | |
351 | var startIndex = {}; | |
352 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
353 | var selections = treeView.selection.getRangeCount(); | |
354 | - | |
355 | + | |
356 | this.copy(); | |
357 | ||
358 | // If there is 1 selection | |
359 | if(selections == 1) | |
360 | - { | |
361 | + { | |
362 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
363 | - | |
364 | + | |
365 | // If more than one item is selected | |
366 | if(endIndex.value - startIndex.value > 0) | |
367 | { | |
368 | @@ -135,13 +136,13 @@ | |
369 | else | |
370 | { | |
371 | var selectedItem = treeView.getItemAtIndex(startIndex.value); | |
372 | - | |
373 | + | |
374 | // If an item is selected | |
375 | if(selectedItem) | |
376 | { | |
377 | UserAgentSwitcherDOM.removeElement(selectedItem); | |
378 | } | |
379 | - } | |
380 | + } | |
381 | } | |
382 | else | |
383 | { | |
384 | @@ -154,7 +155,7 @@ | |
385 | } | |
386 | } | |
387 | }, | |
388 | - | |
389 | + | |
390 | // Deletes user agents | |
391 | deleteUserAgents: function() | |
392 | { | |
393 | @@ -162,12 +163,12 @@ | |
394 | var startIndex = {}; | |
395 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
396 | var selections = treeView.selection.getRangeCount(); | |
397 | - | |
398 | + | |
399 | // If there is 1 selection | |
400 | if(selections == 1) | |
401 | - { | |
402 | + { | |
403 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
404 | - | |
405 | + | |
406 | // If more than one item is selected | |
407 | if(endIndex.value - startIndex.value > 0) | |
408 | { | |
409 | @@ -180,13 +181,13 @@ | |
410 | else | |
411 | { | |
412 | var selectedItem = treeView.getItemAtIndex(startIndex.value); | |
413 | - | |
414 | + | |
415 | // If an item is selected and is either a separator, or a folder or user agent and the deletion is confirmed | |
416 | if(selectedItem && (this.isSeparatorSelected(selectedItem) || (selectedItem.hasAttribute("container") && confirm(UserAgentSwitcherStringBundle.getString("deleteFolderConfirmation"))) || (!selectedItem.hasAttribute("container") && confirm(UserAgentSwitcherStringBundle.getString("deleteUserAgentConfirmation"))))) | |
417 | { | |
418 | UserAgentSwitcherDOM.removeElement(selectedItem); | |
419 | - } | |
420 | - } | |
421 | + } | |
422 | + } | |
423 | } | |
424 | else | |
425 | { | |
426 | @@ -197,26 +198,26 @@ | |
427 | for(var i = selections - 1; i >= 0; i--) | |
428 | { | |
429 | treeView.selection.getRangeAt(i, startIndex, endIndex); | |
430 | - | |
431 | + | |
432 | this.deleteSelections(treeView, startIndex, endIndex); | |
433 | } | |
434 | } | |
435 | } | |
436 | }, | |
437 | - | |
438 | + | |
439 | // Deletes selections | |
440 | deleteSelections: function(treeView, startIndex, endIndex) | |
441 | { | |
442 | var endValue = endIndex.value; | |
443 | var startValue = startIndex.value; | |
444 | - | |
445 | + | |
446 | // Loop through the items in reverse order to delete without changing the index | |
447 | for(var index = endValue; index >= startValue; index--) | |
448 | { | |
449 | UserAgentSwitcherDOM.removeElement(treeView.getItemAtIndex(index)); | |
450 | } | |
451 | }, | |
452 | - | |
453 | + | |
454 | // Edit user agents | |
455 | edit: function() | |
456 | { | |
457 | @@ -224,11 +225,11 @@ | |
458 | var selectedItem = null; | |
459 | var startIndex = {}; | |
460 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
461 | - | |
462 | + | |
463 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
464 | ||
465 | selectedItem = treeView.getItemAtIndex(startIndex.value); | |
466 | - | |
467 | + | |
468 | // If the selected item is set | |
469 | if(selectedItem) | |
470 | { | |
471 | @@ -243,7 +244,7 @@ | |
472 | } | |
473 | } | |
474 | }, | |
475 | - | |
476 | + | |
477 | // Edits a folder | |
478 | editFolder: function(selectedItem) | |
479 | { | |
480 | @@ -251,7 +252,7 @@ | |
481 | if(selectedItem) | |
482 | { | |
483 | window.openDialog("chrome://useragentswitcher/content/options/dialogs/folder.xul", "useragentswitcher-folder-dialog", "centerscreen,chrome,modal,resizable", "edit", selectedItem.getAttribute("label")); | |
484 | - | |
485 | + | |
486 | // If the folder is set | |
487 | if(this.folder) | |
488 | { | |
489 | @@ -259,15 +260,15 @@ | |
490 | } | |
491 | } | |
492 | }, | |
493 | - | |
494 | + | |
495 | // Edits a user agent | |
496 | editUserAgent: function(selectedItem) | |
497 | { | |
498 | // If an item is selected | |
499 | if(selectedItem) | |
500 | { | |
501 | - window.openDialog("chrome://useragentswitcher/content/options/dialogs/useragent.xul", "useragentswitcher-user-agent-dialog", "centerscreen,chrome,modal,resizable", "edit", selectedItem.getAttribute("useragentswitcherappcodename"), selectedItem.getAttribute("useragentswitcherappname"), selectedItem.getAttribute("useragentswitcherappversion"), selectedItem.getAttribute("label"), selectedItem.getAttribute("useragentswitcherplatform"), selectedItem.getAttribute("useragentswitcheruseragent"), selectedItem.getAttribute("useragentswitchervendor"), selectedItem.getAttribute("useragentswitchervendorsub")); | |
502 | - | |
503 | + window.openDialog("chrome://useragentswitcher/content/options/dialogs/useragent.xul", "useragentswitcher-user-agent-dialog", "centerscreen,chrome,modal,resizable", "edit", selectedItem.getAttribute("useragentswitcherappcodename"), selectedItem.getAttribute("useragentswitcherappname"), selectedItem.getAttribute("useragentswitcherappversion"), selectedItem.getAttribute("label"), selectedItem.getAttribute("useragentswitcherplatform"), selectedItem.getAttribute("useragentswitcheroscpu"), selectedItem.getAttribute("useragentswitcheruseragent"), selectedItem.getAttribute("useragentswitchervendor"), selectedItem.getAttribute("useragentswitchervendorsub")); | |
504 | + | |
505 | // If the description is set | |
506 | if(this.description) | |
507 | { | |
508 | @@ -276,32 +277,33 @@ | |
509 | selectedItem.setAttribute("useragentswitcherappname", this.appName); | |
510 | selectedItem.setAttribute("useragentswitcherappversion", this.appVersion); | |
511 | selectedItem.setAttribute("useragentswitcherplatform", this.platform); | |
512 | + selectedItem.setAttribute("useragentswitcheroscpu", this.oscpu); | |
513 | selectedItem.setAttribute("useragentswitcheruseragent", this.userAgent); | |
514 | selectedItem.setAttribute("useragentswitchervendor", this.vendor); | |
515 | selectedItem.setAttribute("useragentswitchervendorsub", this.vendorSub); | |
516 | } | |
517 | } | |
518 | }, | |
519 | - | |
520 | + | |
521 | // Exports user agents to a file | |
522 | exportUserAgents: function() | |
523 | { | |
524 | var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); | |
525 | var result = null; | |
526 | - | |
527 | + | |
528 | filePicker.defaultExtension = "xml"; | |
529 | filePicker.defaultString = "useragentswitcher.xml"; | |
530 | - | |
531 | + | |
532 | filePicker.appendFilter(UserAgentSwitcherStringBundle.getString("xmlFileDescription"), "*.xml"); | |
533 | filePicker.init(window, UserAgentSwitcherStringBundle.getString("exportUserAgents"), filePicker.modeSave); | |
534 | - | |
535 | + | |
536 | result = filePicker.show(); | |
537 | - | |
538 | + | |
539 | // If the user selected a file | |
540 | if(result == filePicker.returnOK || result == filePicker.returnReplace) | |
541 | { | |
542 | var errorMessage = UserAgentSwitcherExporter.export(filePicker.file); | |
543 | - | |
544 | + | |
545 | // If there is an error message | |
546 | if(errorMessage) | |
547 | { | |
548 | @@ -309,20 +311,20 @@ | |
549 | } | |
550 | } | |
551 | }, | |
552 | - | |
553 | + | |
554 | // Imports user agents from a file | |
555 | importUserAgents: function() | |
556 | { | |
557 | var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); | |
558 | - | |
559 | + | |
560 | filePicker.appendFilter(UserAgentSwitcherStringBundle.getString("xmlFileDescription"), "*.xml"); | |
561 | filePicker.init(window, UserAgentSwitcherStringBundle.getString("importUserAgents"), filePicker.modeOpen); | |
562 | - | |
563 | + | |
564 | // If the user selected an XML file | |
565 | if(filePicker.show() == filePicker.returnOK) | |
566 | { | |
567 | var errorMessage = UserAgentSwitcherImporter.import(UserAgentSwitcherImporter.importTypeOptions, filePicker.file, false); | |
568 | - | |
569 | + | |
570 | // If there is an error message | |
571 | if(errorMessage) | |
572 | { | |
573 | @@ -330,12 +332,12 @@ | |
574 | } | |
575 | } | |
576 | }, | |
577 | - | |
578 | + | |
579 | // Initializes the options | |
580 | initialize: function() | |
581 | { | |
582 | UserAgentSwitcherImporter.import(UserAgentSwitcherImporter.importTypeOptions, UserAgentSwitcherImporter.getUserAgentFileLocation(), false); | |
583 | - | |
584 | + | |
585 | // If the hide menu preference is set | |
586 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher.menu.hide")) | |
587 | { | |
588 | @@ -355,10 +357,10 @@ | |
589 | { | |
590 | document.getElementById("useragentswitcher-import-overwrite").checked = false; | |
591 | } | |
592 | - | |
593 | + | |
594 | document.getElementById("useragentswitcher-options-user-agents").addEventListener("dblclick", UserAgentSwitcherOptions.treeDoubleClick, false); | |
595 | }, | |
596 | - | |
597 | + | |
598 | // Returns true if a separator is selected | |
599 | isSeparatorSelected: function(selectedItem) | |
600 | { | |
601 | @@ -366,11 +368,11 @@ | |
602 | if(selectedItem && selectedItem.nodeName == "treeseparator") | |
603 | { | |
604 | return true; | |
605 | - } | |
606 | - | |
607 | + } | |
608 | + | |
609 | return false; | |
610 | }, | |
611 | - | |
612 | + | |
613 | // Moves the selected item down | |
614 | moveDown: function() | |
615 | { | |
616 | @@ -379,11 +381,11 @@ | |
617 | var startIndex = {}; | |
618 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
619 | var treeSelection = treeView.selection; | |
620 | - | |
621 | + | |
622 | treeSelection.getRangeAt(0, startIndex, endIndex); | |
623 | ||
624 | selectedItem = treeView.getItemAtIndex(startIndex.value); | |
625 | - | |
626 | + | |
627 | // If the selected item is set | |
628 | if(selectedItem) | |
629 | { | |
630 | @@ -391,7 +393,7 @@ | |
631 | treeSelection.select(startIndex.value + 1); | |
632 | } | |
633 | }, | |
634 | - | |
635 | + | |
636 | // Moves the selected item up | |
637 | moveUp: function() | |
638 | { | |
639 | @@ -400,11 +402,11 @@ | |
640 | var startIndex = {}; | |
641 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
642 | var treeSelection = treeView.selection; | |
643 | - | |
644 | + | |
645 | treeSelection.getRangeAt(0, startIndex, endIndex); | |
646 | ||
647 | selectedItem = treeView.getItemAtIndex(startIndex.value); | |
648 | - | |
649 | + | |
650 | // If the selected item is set | |
651 | if(selectedItem) | |
652 | { | |
653 | @@ -412,12 +414,12 @@ | |
654 | treeSelection.select(startIndex.value - 1); | |
655 | } | |
656 | }, | |
657 | - | |
658 | + | |
659 | // Adds a new folder | |
660 | newFolder: function() | |
661 | { | |
662 | window.openDialog("chrome://useragentswitcher/content/options/dialogs/folder.xul", "useragentswitcher-folder-dialog", "centerscreen,chrome,modal,resizable", "new"); | |
663 | - | |
664 | + | |
665 | // If the folder is set | |
666 | if(this.folder) | |
667 | { | |
668 | @@ -434,29 +436,29 @@ | |
669 | treeRow.appendChild(treeCell); | |
670 | treeItem.appendChild(treeRow); | |
671 | treeItem.appendChild(treeChildren); | |
672 | - | |
673 | - this.addTreeItemToSelection(treeItem); | |
674 | + | |
675 | + this.addTreeItemToSelection(treeItem); | |
676 | } | |
677 | }, | |
678 | - | |
679 | + | |
680 | // Adds a new separator | |
681 | newSeparator: function() | |
682 | { | |
683 | - this.addTreeItemToSelection(document.createElement("treeseparator")); | |
684 | + this.addTreeItemToSelection(document.createElement("treeseparator")); | |
685 | }, | |
686 | - | |
687 | + | |
688 | // Adds a new user agent | |
689 | newUserAgent: function() | |
690 | { | |
691 | window.openDialog("chrome://useragentswitcher/content/options/dialogs/useragent.xul", "useragentswitcher-user-agent-dialog", "centerscreen,chrome,modal,resizable", "new"); | |
692 | - | |
693 | + | |
694 | // If the description is set | |
695 | if(this.description) | |
696 | { | |
697 | var treeCell = document.createElement("treecell"); | |
698 | var treeItem = document.createElement("treeitem"); | |
699 | var treeRow = document.createElement("treerow"); | |
700 | - | |
701 | + | |
702 | treeCell.setAttribute("label", this.description); | |
703 | treeRow.appendChild(treeCell); | |
704 | treeItem.appendChild(treeRow); | |
705 | @@ -465,19 +467,20 @@ | |
706 | treeCell.setAttribute("useragentswitcherappname", this.appName); | |
707 | treeCell.setAttribute("useragentswitcherappversion", this.appVersion); | |
708 | treeCell.setAttribute("useragentswitcherplatform", this.platform); | |
709 | + treeCell.setAttribute("useragentswitcheroscpu", this.oscpu); | |
710 | treeCell.setAttribute("useragentswitcheruseragent", this.userAgent); | |
711 | treeCell.setAttribute("useragentswitchervendor", this.vendor); | |
712 | treeCell.setAttribute("useragentswitchervendorsub", this.vendorSub); | |
713 | - | |
714 | - this.addTreeItemToSelection(treeItem); | |
715 | + | |
716 | + this.addTreeItemToSelection(treeItem); | |
717 | } | |
718 | }, | |
719 | - | |
720 | + | |
721 | // Opens the user agents page | |
722 | openUserAgentsPage: function() | |
723 | { | |
724 | var parentWindow = null; | |
725 | - | |
726 | + | |
727 | // If there is a parent window | |
728 | if(window.opener) | |
729 | { | |
730 | @@ -491,16 +494,16 @@ | |
731 | parentWindow = window.opener; | |
732 | } | |
733 | } | |
734 | - | |
735 | + | |
736 | // If a parent window was found | |
737 | if(parentWindow) | |
738 | { | |
739 | parentWindow.getBrowser().selectedTab = parentWindow.getBrowser().addTab("http://chrispederick.com/work/user-agent-switcher/user-agents/"); | |
740 | - | |
741 | + | |
742 | window.close(); | |
743 | } | |
744 | }, | |
745 | - | |
746 | + | |
747 | // Pastes user agents | |
748 | paste: function() | |
749 | { | |
750 | @@ -510,12 +513,12 @@ | |
751 | var startIndex = {}; | |
752 | var treeView = document.getElementById("useragentswitcher-options-tree").view; | |
753 | var selections = treeView.selection.getRangeCount(); | |
754 | - | |
755 | + | |
756 | // If there are no selections | |
757 | if(selections == 0) | |
758 | { | |
759 | var userAgents = document.getElementById("useragentswitcher-options-user-agents"); | |
760 | - | |
761 | + | |
762 | // Loop through the clipboard | |
763 | for(var i = 0; i < clipboardLength; i++) | |
764 | { | |
765 | @@ -525,9 +528,9 @@ | |
766 | else | |
767 | { | |
768 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
769 | - | |
770 | + | |
771 | selectedItem = treeView.getItemAtIndex(startIndex.value); | |
772 | - | |
773 | + | |
774 | // If the selected item is set | |
775 | if(selectedItem) | |
776 | { | |
777 | @@ -551,24 +554,24 @@ | |
778 | } | |
779 | } | |
780 | }, | |
781 | - | |
782 | + | |
783 | // Resets the user's options | |
784 | resetOptions: function() | |
785 | { | |
786 | var promptServiceInterface = Components.interfaces.nsIPromptService; | |
787 | - | |
788 | + | |
789 | // If the reset is confirmed | |
790 | if(Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(promptServiceInterface).confirmEx(null, UserAgentSwitcherStringBundle.getString("resetConfirmationMessage"), UserAgentSwitcherStringBundle.getString("resetConfirmation"), promptServiceInterface.BUTTON_TITLE_IS_STRING * promptServiceInterface.BUTTON_POS_0 + promptServiceInterface.BUTTON_TITLE_CANCEL * promptServiceInterface.BUTTON_POS_1, UserAgentSwitcherStringBundle.getString("reset"), null, null, null, {}) == 0) | |
791 | { | |
792 | UserAgentSwitcherPreferences.deletePreferenceBranch("useragentswitcher."); | |
793 | UserAgentSwitcherUpgrade.setVersion(); | |
794 | - UserAgentSwitcherDOM.removeAllChildElements(document.getElementById("useragentswitcher-options-user-agents")); | |
795 | + UserAgentSwitcherDOM.removeAllChildElements(document.getElementById("useragentswitcher-options-user-agents")); | |
796 | UserAgentSwitcherImporter.reset(); | |
797 | - | |
798 | + | |
799 | this.initialize(); | |
800 | } | |
801 | }, | |
802 | - | |
803 | + | |
804 | // Saves the user's options | |
805 | saveOptions: function() | |
806 | { | |
807 | @@ -578,13 +581,13 @@ | |
808 | UserAgentSwitcherExporter.export(UserAgentSwitcherExporter.getUserAgentFileLocation()); | |
809 | UserAgentSwitcherImporter.import(UserAgentSwitcherImporter.importTypeMenu, UserAgentSwitcherImporter.getUserAgentFileLocation(), false); | |
810 | }, | |
811 | - | |
812 | + | |
813 | // Handles a user agent being selected | |
814 | selectUserAgent: function(tree) | |
815 | { | |
816 | var treeView = tree.view; | |
817 | var selections = treeView.selection.getRangeCount(); | |
818 | - | |
819 | + | |
820 | // If there are no selections | |
821 | if(selections == 0) | |
822 | { | |
823 | @@ -597,9 +600,9 @@ | |
824 | { | |
825 | var endIndex = {}; | |
826 | var startIndex = {}; | |
827 | - | |
828 | + | |
829 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
830 | - | |
831 | + | |
832 | // If more than one item is selected | |
833 | if(endIndex.value - startIndex.value > 0) | |
834 | { | |
835 | @@ -607,8 +610,8 @@ | |
836 | if(document.getElementById("useragentswitcher-delete-button").hasAttribute("disabled")) | |
837 | { | |
838 | document.getElementById("useragentswitcher-delete-button").removeAttribute("disabled"); | |
839 | - } | |
840 | - | |
841 | + } | |
842 | + | |
843 | document.getElementById("useragentswitcher-edit-button").setAttribute("disabled", true); | |
844 | document.getElementById("useragentswitcher-move-down-button").setAttribute("disabled", true); | |
845 | document.getElementById("useragentswitcher-move-up-button").setAttribute("disabled", true); | |
846 | @@ -616,23 +619,23 @@ | |
847 | else | |
848 | { | |
849 | var selectedItem = treeView.getItemAtIndex(startIndex.value); | |
850 | - | |
851 | + | |
852 | // If the delete button is disabled | |
853 | if(document.getElementById("useragentswitcher-delete-button").hasAttribute("disabled")) | |
854 | { | |
855 | document.getElementById("useragentswitcher-delete-button").removeAttribute("disabled"); | |
856 | - } | |
857 | - | |
858 | + } | |
859 | + | |
860 | // If a separator is selected | |
861 | if(this.isSeparatorSelected(treeView.getItemAtIndex(startIndex.value))) | |
862 | { | |
863 | document.getElementById("useragentswitcher-edit-button").setAttribute("disabled", true); | |
864 | - } | |
865 | + } | |
866 | else if(document.getElementById("useragentswitcher-edit-button").hasAttribute("disabled")) | |
867 | { | |
868 | document.getElementById("useragentswitcher-edit-button").removeAttribute("disabled"); | |
869 | - } | |
870 | - | |
871 | + } | |
872 | + | |
873 | // If the selected item is set and has a previous sibling | |
874 | if(selectedItem && selectedItem.previousSibling) | |
875 | { | |
876 | @@ -640,13 +643,13 @@ | |
877 | if(document.getElementById("useragentswitcher-move-up-button").hasAttribute("disabled")) | |
878 | { | |
879 | document.getElementById("useragentswitcher-move-up-button").removeAttribute("disabled"); | |
880 | - } | |
881 | + } | |
882 | } | |
883 | else | |
884 | { | |
885 | document.getElementById("useragentswitcher-move-up-button").setAttribute("disabled", true); | |
886 | } | |
887 | - | |
888 | + | |
889 | // If the selected item is set and has a next sibling | |
890 | if(selectedItem && selectedItem.nextSibling) | |
891 | { | |
892 | @@ -654,13 +657,13 @@ | |
893 | if(document.getElementById("useragentswitcher-move-down-button").hasAttribute("disabled")) | |
894 | { | |
895 | document.getElementById("useragentswitcher-move-down-button").removeAttribute("disabled"); | |
896 | - } | |
897 | + } | |
898 | } | |
899 | else | |
900 | { | |
901 | document.getElementById("useragentswitcher-move-down-button").setAttribute("disabled", true); | |
902 | } | |
903 | - } | |
904 | + } | |
905 | } | |
906 | else | |
907 | { | |
908 | @@ -668,21 +671,21 @@ | |
909 | if(document.getElementById("useragentswitcher-delete-button").hasAttribute("disabled")) | |
910 | { | |
911 | document.getElementById("useragentswitcher-delete-button").removeAttribute("disabled"); | |
912 | - } | |
913 | - | |
914 | + } | |
915 | + | |
916 | document.getElementById("useragentswitcher-edit-button").setAttribute("disabled", true); | |
917 | document.getElementById("useragentswitcher-move-down-button").setAttribute("disabled", true); | |
918 | document.getElementById("useragentswitcher-move-up-button").setAttribute("disabled", true); | |
919 | } | |
920 | }, | |
921 | - | |
922 | + | |
923 | // Handles double clicking on the tree | |
924 | treeDoubleClick: function(event) | |
925 | { | |
926 | var tree = document.getElementById("useragentswitcher-options-tree"); | |
927 | var rowPosition = tree.treeBoxObject.getRowAt(event.clientX, event.clientY); | |
928 | var treeItem = tree.view.getItemAtIndex(rowPosition); | |
929 | - | |
930 | + | |
931 | // If the tree item is set | |
932 | if(treeItem) | |
933 | { | |
934 | @@ -693,13 +696,13 @@ | |
935 | } | |
936 | } | |
937 | }, | |
938 | - | |
939 | + | |
940 | // Uninitializes the options | |
941 | uninitialize: function() | |
942 | { | |
943 | document.getElementById("useragentswitcher-options-user-agents").removeEventListener("dblclick", UserAgentSwitcherOptions.treeDoubleClick, false); | |
944 | }, | |
945 | - | |
946 | + | |
947 | // Updates the context menu | |
948 | updateContextMenu: function() | |
949 | { | |
950 | @@ -709,7 +712,7 @@ | |
951 | // If the clipboard is empty | |
952 | if(this.clipboard.length == 0) | |
953 | { | |
954 | - document.getElementById("useragentswitcher-paste").setAttribute("disabled", true); | |
955 | + document.getElementById("useragentswitcher-paste").setAttribute("disabled", true); | |
956 | } | |
957 | ||
958 | // If there are no selections | |
959 | @@ -721,20 +724,20 @@ | |
960 | document.getElementById("useragentswitcher-edit-menu").setAttribute("disabled", true); | |
961 | document.getElementById("useragentswitcher-move-up").setAttribute("disabled", true); | |
962 | document.getElementById("useragentswitcher-move-down").setAttribute("disabled", true); | |
963 | - | |
964 | + | |
965 | // If the clipboard is not empty and the paste menu is disabled | |
966 | if(this.clipboard.length > 0 && document.getElementById("useragentswitcher-paste").hasAttribute("disabled")) | |
967 | { | |
968 | document.getElementById("useragentswitcher-paste").removeAttribute("disabled"); | |
969 | - } | |
970 | + } | |
971 | } | |
972 | else if(selections == 1) | |
973 | { | |
974 | var endIndex = {}; | |
975 | var startIndex = {}; | |
976 | - | |
977 | + | |
978 | treeView.selection.getRangeAt(0, startIndex, endIndex); | |
979 | - | |
980 | + | |
981 | // If more than one item is selected | |
982 | if(endIndex.value - startIndex.value > 0) | |
983 | { | |
984 | @@ -742,20 +745,20 @@ | |
985 | if(document.getElementById("useragentswitcher-copy").hasAttribute("disabled")) | |
986 | { | |
987 | document.getElementById("useragentswitcher-copy").removeAttribute("disabled"); | |
988 | - } | |
989 | - | |
990 | + } | |
991 | + | |
992 | // If the cut menu is disabled | |
993 | if(document.getElementById("useragentswitcher-cut").hasAttribute("disabled")) | |
994 | { | |
995 | document.getElementById("useragentswitcher-cut").removeAttribute("disabled"); | |
996 | - } | |
997 | - | |
998 | + } | |
999 | + | |
1000 | // If the delete menu is disabled | |
1001 | if(document.getElementById("useragentswitcher-delete-menu").hasAttribute("disabled")) | |
1002 | { | |
1003 | document.getElementById("useragentswitcher-delete-menu").removeAttribute("disabled"); | |
1004 | - } | |
1005 | - | |
1006 | + } | |
1007 | + | |
1008 | document.getElementById("useragentswitcher-edit-menu").setAttribute("disabled", true); | |
1009 | document.getElementById("useragentswitcher-move-up").setAttribute("disabled", true); | |
1010 | document.getElementById("useragentswitcher-move-down").setAttribute("disabled", true); | |
1011 | @@ -764,41 +767,41 @@ | |
1012 | else | |
1013 | { | |
1014 | var selectedItem = treeView.getItemAtIndex(startIndex.value); | |
1015 | - | |
1016 | + | |
1017 | // If the copy menu is disabled | |
1018 | if(document.getElementById("useragentswitcher-copy").hasAttribute("disabled")) | |
1019 | { | |
1020 | document.getElementById("useragentswitcher-copy").removeAttribute("disabled"); | |
1021 | - } | |
1022 | - | |
1023 | + } | |
1024 | + | |
1025 | // If the cut menu is disabled | |
1026 | if(document.getElementById("useragentswitcher-cut").hasAttribute("disabled")) | |
1027 | { | |
1028 | document.getElementById("useragentswitcher-cut").removeAttribute("disabled"); | |
1029 | - } | |
1030 | - | |
1031 | + } | |
1032 | + | |
1033 | // If the delete menu is disabled | |
1034 | if(document.getElementById("useragentswitcher-delete-menu").hasAttribute("disabled")) | |
1035 | { | |
1036 | document.getElementById("useragentswitcher-delete-menu").removeAttribute("disabled"); | |
1037 | - } | |
1038 | - | |
1039 | + } | |
1040 | + | |
1041 | // If a separator is selected | |
1042 | if(this.isSeparatorSelected(selectedItem)) | |
1043 | { | |
1044 | document.getElementById("useragentswitcher-edit-menu").setAttribute("disabled", true); | |
1045 | - } | |
1046 | + } | |
1047 | else if(document.getElementById("useragentswitcher-edit-menu").hasAttribute("disabled")) | |
1048 | { | |
1049 | document.getElementById("useragentswitcher-edit-menu").removeAttribute("disabled"); | |
1050 | - } | |
1051 | - | |
1052 | + } | |
1053 | + | |
1054 | // If the clipboard is not empty and the paste menu is disabled | |
1055 | if(this.clipboard.length > 0 && document.getElementById("useragentswitcher-paste").hasAttribute("disabled")) | |
1056 | { | |
1057 | document.getElementById("useragentswitcher-paste").removeAttribute("disabled"); | |
1058 | - } | |
1059 | - | |
1060 | + } | |
1061 | + | |
1062 | // If the selected item is set and has a previous sibling | |
1063 | if(selectedItem && selectedItem.previousSibling) | |
1064 | { | |
1065 | @@ -806,13 +809,13 @@ | |
1066 | if(document.getElementById("useragentswitcher-move-up").hasAttribute("disabled")) | |
1067 | { | |
1068 | document.getElementById("useragentswitcher-move-up").removeAttribute("disabled"); | |
1069 | - } | |
1070 | + } | |
1071 | } | |
1072 | else | |
1073 | { | |
1074 | document.getElementById("useragentswitcher-move-up").setAttribute("disabled", true); | |
1075 | } | |
1076 | - | |
1077 | + | |
1078 | // If the selected item is set and has a next sibling | |
1079 | if(selectedItem && selectedItem.nextSibling) | |
1080 | { | |
1081 | @@ -820,13 +823,13 @@ | |
1082 | if(document.getElementById("useragentswitcher-move-down").hasAttribute("disabled")) | |
1083 | { | |
1084 | document.getElementById("useragentswitcher-move-down").removeAttribute("disabled"); | |
1085 | - } | |
1086 | + } | |
1087 | } | |
1088 | else | |
1089 | { | |
1090 | document.getElementById("useragentswitcher-move-down").setAttribute("disabled", true); | |
1091 | } | |
1092 | - } | |
1093 | + } | |
1094 | } | |
1095 | else | |
1096 | { | |
1097 | @@ -834,20 +837,20 @@ | |
1098 | if(document.getElementById("useragentswitcher-copy").hasAttribute("disabled")) | |
1099 | { | |
1100 | document.getElementById("useragentswitcher-copy").removeAttribute("disabled"); | |
1101 | - } | |
1102 | - | |
1103 | + } | |
1104 | + | |
1105 | // If the cut menu is disabled | |
1106 | if(document.getElementById("useragentswitcher-cut").hasAttribute("disabled")) | |
1107 | { | |
1108 | document.getElementById("useragentswitcher-cut").removeAttribute("disabled"); | |
1109 | - } | |
1110 | - | |
1111 | + } | |
1112 | + | |
1113 | // If the delete menu is disabled | |
1114 | if(document.getElementById("useragentswitcher-delete-menu").hasAttribute("disabled")) | |
1115 | { | |
1116 | document.getElementById("useragentswitcher-delete-menu").removeAttribute("disabled"); | |
1117 | - } | |
1118 | - | |
1119 | + } | |
1120 | + | |
1121 | document.getElementById("useragentswitcher-edit-menu").setAttribute("disabled", true); | |
1122 | document.getElementById("useragentswitcher-move-up").setAttribute("disabled", true); | |
1123 | document.getElementById("useragentswitcher-move-down").setAttribute("disabled", true); | |
1124 | diff -rU3 original/chrome/content/useragentswitcher/upgrade.js profexer/chrome/content/useragentswitcher/upgrade.js | |
1125 | --- original/chrome/content/useragentswitcher/upgrade.js 2011-01-04 18:53:34.000000000 +0200 | |
1126 | +++ profexer/chrome/content/useragentswitcher/upgrade.js 2012-06-15 23:49:05.000000000 +0300 | |
1127 | @@ -33,13 +33,13 @@ | |
1128 | var userAgentFile = null; | |
1129 | var xmlDocument = document.implementation.createDocument("", "", null); | |
1130 | var rootElement = xmlDocument.createElement("useragentswitcher"); | |
1131 | - | |
1132 | + | |
1133 | // If the user agent directory does not exist | |
1134 | if(!UserAgentSwitcherImporter.getUserAgentDirectoryLocation().exists()) | |
1135 | { | |
1136 | UserAgentSwitcherImporter.createUserAgentDirectory(); | |
1137 | } | |
1138 | - | |
1139 | + | |
1140 | // If the user agent file exists | |
1141 | if(UserAgentSwitcherImporter.getUserAgentFileLocation().exists()) | |
1142 | { | |
1143 | @@ -51,12 +51,12 @@ | |
1144 | { | |
1145 | userAgentFile = UserAgentSwitcherImporter.createUserAgentFile(); | |
1146 | } | |
1147 | - | |
1148 | + | |
1149 | // Loop through the user agents | |
1150 | for(var i = 1; i <= userAgentCount; i++) | |
1151 | { | |
1152 | description = UserAgentSwitcherPreferences.getStringPreference("useragentswitcher." + i + ".description"); | |
1153 | - | |
1154 | + | |
1155 | // If the description is set | |
1156 | if(description) | |
1157 | { | |
1158 | @@ -73,7 +73,7 @@ | |
1159 | { | |
1160 | userAgent.setAttribute("useragent", ""); | |
1161 | } | |
1162 | - | |
1163 | + | |
1164 | // If the app code name is set | |
1165 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".appcodename")) | |
1166 | { | |
1167 | @@ -83,7 +83,7 @@ | |
1168 | { | |
1169 | userAgent.setAttribute("appcodename", ""); | |
1170 | } | |
1171 | - | |
1172 | + | |
1173 | // If the app name is set | |
1174 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".appname")) | |
1175 | { | |
1176 | @@ -93,7 +93,7 @@ | |
1177 | { | |
1178 | userAgent.setAttribute("appname", ""); | |
1179 | } | |
1180 | - | |
1181 | + | |
1182 | // If the app version is set | |
1183 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".appversion")) | |
1184 | { | |
1185 | @@ -103,7 +103,7 @@ | |
1186 | { | |
1187 | userAgent.setAttribute("appversion", ""); | |
1188 | } | |
1189 | - | |
1190 | + | |
1191 | // If the platform is set | |
1192 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".platform")) | |
1193 | { | |
1194 | @@ -113,7 +113,18 @@ | |
1195 | { | |
1196 | userAgent.setAttribute("platform", ""); | |
1197 | } | |
1198 | - | |
1199 | + | |
1200 | + // PROFEDIT: If the oscpu is set | |
1201 | + if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".oscpu")) | |
1202 | + { | |
1203 | + userAgent.setAttribute("oscpu", UserAgentSwitcherPreferences.getStringPreference("useragentswitcher." + i + ".oscpu")); | |
1204 | + } | |
1205 | + else | |
1206 | + { | |
1207 | + userAgent.setAttribute("oscpu", ""); | |
1208 | + } | |
1209 | + // ENDPROFEDIT | |
1210 | + | |
1211 | // If the vendor is set | |
1212 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".vendor")) | |
1213 | { | |
1214 | @@ -123,7 +134,7 @@ | |
1215 | { | |
1216 | userAgent.setAttribute("vendor", ""); | |
1217 | } | |
1218 | - | |
1219 | + | |
1220 | // If the vendor sub is set | |
1221 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher." + i + ".vendorsub")) | |
1222 | { | |
1223 | @@ -133,12 +144,12 @@ | |
1224 | { | |
1225 | userAgent.setAttribute("vendorsub", ""); | |
1226 | } | |
1227 | - } | |
1228 | + } | |
1229 | ||
1230 | rootElement.appendChild(userAgent); | |
1231 | UserAgentSwitcherPreferences.deletePreferenceBranch("useragentswitcher." + i + "."); | |
1232 | } | |
1233 | - | |
1234 | + | |
1235 | UserAgentSwitcherPreferences.deletePreference("useragentswitcher.user.agents.count"); | |
1236 | ||
1237 | // If old user agents could be migrated | |
1238 | @@ -148,11 +159,11 @@ | |
1239 | var xmlSerializer = new XMLSerializer(); | |
1240 | ||
1241 | xmlDocument.appendChild(rootElement); | |
1242 | - | |
1243 | + | |
1244 | outputStream.init(userAgentFile, 0x04 | 0x08 | 0x20, 00644, null); | |
1245 | xmlSerializer.serializeToStream(xmlDocument, outputStream, "utf-8"); | |
1246 | outputStream.close(); | |
1247 | - } | |
1248 | + } | |
1249 | else | |
1250 | { | |
1251 | UserAgentSwitcherImporter.reset(); | |
1252 | @@ -163,10 +174,10 @@ | |
1253 | openUpgradePage: function() | |
1254 | { | |
1255 | var windowContent = window.getBrowser(); | |
1256 | - | |
1257 | + | |
1258 | windowContent.removeEventListener("load", UserAgentSwitcherUpgrade.openUpgradePage, false); | |
1259 | ||
1260 | - window.setTimeout(function() { windowContent.selectedTab = windowContent.addTab("http://chrispederick.com/work/user-agent-switcher/installed/" + UserAgentSwitcherUpgrade.getVersion().replace(/\./g, "") + "/"); }, 0); | |
1261 | + window.setTimeout(function() { windowContent.selectedTab = windowContent.addTab("http://chrispederick.com/work/user-agent-switcher/installed/" + UserAgentSwitcherUpgrade.getVersion().replace(/\./g, "") + "/"); }, 0); | |
1262 | }, | |
1263 | ||
1264 | // Parses the version number | |
1265 | @@ -178,13 +189,13 @@ | |
1266 | var splitVersion = version.split("."); | |
1267 | var parsedVersion = splitVersion[0] + "."; | |
1268 | var splitVersionLength = splitVersion.length; | |
1269 | - | |
1270 | + | |
1271 | // Loop through the remaining parts of the version | |
1272 | for(var i = 1; i < splitVersionLength; i++) | |
1273 | { | |
1274 | parsedVersion += splitVersion[i]; | |
1275 | } | |
1276 | - | |
1277 | + | |
1278 | return parseFloat(parsedVersion); | |
1279 | } | |
1280 | else | |
1281 | @@ -192,13 +203,13 @@ | |
1282 | return 0; | |
1283 | } | |
1284 | }, | |
1285 | - | |
1286 | + | |
1287 | // Sets the version | |
1288 | setVersion: function() | |
1289 | { | |
1290 | UserAgentSwitcherPreferences.setStringPreference("useragentswitcher.version", UserAgentSwitcherUpgrade.getVersion()); | |
1291 | }, | |
1292 | - | |
1293 | + | |
1294 | // Upgrades the extension | |
1295 | upgrade: function() | |
1296 | { | |
1297 | @@ -217,7 +228,7 @@ | |
1298 | this.installUserAgents(); | |
1299 | ||
1300 | window.getBrowser().addEventListener("load", UserAgentSwitcherUpgrade.openUpgradePage, false); | |
1301 | - | |
1302 | + | |
1303 | UserAgentSwitcherPreferences.setStringPreference("useragentswitcher.version", version); | |
1304 | } | |
1305 | } | |
1306 | diff -rU3 original/chrome/content/useragentswitcher/useragentswitcher.js profexer/chrome/content/useragentswitcher/useragentswitcher.js | |
1307 | --- original/chrome/content/useragentswitcher/useragentswitcher.js 2011-01-04 18:53:34.000000000 +0200 | |
1308 | +++ profexer/chrome/content/useragentswitcher/useragentswitcher.js 2012-06-16 00:09:41.000000000 +0300 | |
1309 | @@ -1,5 +1,5 @@ | |
1310 | // User Agent Switcher | |
1311 | -var UserAgentSwitcher = | |
1312 | +var UserAgentSwitcher = | |
1313 | { | |
1314 | // Displays the about dialog | |
1315 | about: function() | |
1316 | @@ -12,26 +12,26 @@ | |
1317 | { | |
1318 | nsDragAndDrop.drop(event, UserAgentSwitcher); | |
1319 | }, | |
1320 | - | |
1321 | + | |
1322 | // Changes the options | |
1323 | changeOptions: function() | |
1324 | { | |
1325 | var hideMenuPreference = false; | |
1326 | var menu = document.getElementById("useragentswitcher-menu"); | |
1327 | - | |
1328 | + | |
1329 | // If the hide menu preference is set | |
1330 | if(UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher.menu.hide")) | |
1331 | { | |
1332 | hideMenuPreference = UserAgentSwitcherPreferences.getBooleanPreference("useragentswitcher.menu.hide", true); | |
1333 | } | |
1334 | - | |
1335 | + | |
1336 | // If the menu exists | |
1337 | if(menu) | |
1338 | { | |
1339 | menu.setAttribute("hidden", hideMenuPreference); | |
1340 | } | |
1341 | }, | |
1342 | - | |
1343 | + | |
1344 | // Finds the selected user agent and returns it's position and description | |
1345 | findSelectedUserAgent: function() | |
1346 | { | |
1347 | @@ -39,28 +39,28 @@ | |
1348 | var userAgent = null; | |
1349 | var userAgents = document.getElementById("useragentswitcher-popup-menu").getElementsByAttribute("type", "radio"); | |
1350 | var userAgentsLength = userAgents.length; | |
1351 | - | |
1352 | + | |
1353 | selectedUserAgent.description = ""; | |
1354 | selectedUserAgent.position = ""; | |
1355 | - | |
1356 | + | |
1357 | // Loop through the user agents | |
1358 | for(var i = 0; i < userAgentsLength; i++) | |
1359 | { | |
1360 | userAgent = userAgents.item(i); | |
1361 | - | |
1362 | + | |
1363 | // If this is the selected user agent | |
1364 | if(UserAgentSwitcher.isSelectedUserAgent(userAgent)) | |
1365 | { | |
1366 | selectedUserAgent.description = userAgent.getAttribute("label"); | |
1367 | selectedUserAgent.position = i; | |
1368 | - | |
1369 | + | |
1370 | break; | |
1371 | } | |
1372 | } | |
1373 | - | |
1374 | + | |
1375 | return selectedUserAgent; | |
1376 | }, | |
1377 | - | |
1378 | + | |
1379 | // Returns the selected user agents for a particular menu | |
1380 | getIndividualSelectedUserAgents: function(menu) | |
1381 | { | |
1382 | @@ -71,7 +71,7 @@ | |
1383 | { | |
1384 | var subMenus = menu.getElementsByTagName("menu"); | |
1385 | var subMenusLength = subMenus.length; | |
1386 | - | |
1387 | + | |
1388 | userAgents = userAgents.concat(UserAgentSwitcherArray.convertCollectionToArray(menu.getElementsByAttribute("checked", "true"))); | |
1389 | ||
1390 | // Loop through the sub menus | |
1391 | @@ -83,15 +83,15 @@ | |
1392 | ||
1393 | return userAgents; | |
1394 | }, | |
1395 | - | |
1396 | + | |
1397 | // Returns the selected user agents | |
1398 | getSelectedUserAgents: function(windowDocument) | |
1399 | { | |
1400 | return UserAgentSwitcher.getIndividualSelectedUserAgents(windowDocument.getElementById("useragentswitcher-popup-menu")).concat(UserAgentSwitcher.getIndividualSelectedUserAgents(windowDocument.getElementById("useragentswitcher-popup-toolbar"))); | |
1401 | }, | |
1402 | - | |
1403 | + | |
1404 | // Return the supported flavours | |
1405 | - getSupportedFlavours: function() | |
1406 | + getSupportedFlavours: function() | |
1407 | { | |
1408 | var flavourSet = new FlavourSet(); | |
1409 | ||
1410 | @@ -99,13 +99,13 @@ | |
1411 | ||
1412 | return flavourSet; | |
1413 | }, | |
1414 | - | |
1415 | + | |
1416 | // Opens the help | |
1417 | help: function() | |
1418 | { | |
1419 | window.getBrowser().selectedTab = window.getBrowser().addTab("http://chrispederick.com/work/user-agent-switcher/help/"); | |
1420 | }, | |
1421 | - | |
1422 | + | |
1423 | // Initializes the extension | |
1424 | initialize: function(event) | |
1425 | { | |
1426 | @@ -117,13 +117,13 @@ | |
1427 | UserAgentSwitcherUpgrade.upgrade(); | |
1428 | UserAgentSwitcherImporter.import(UserAgentSwitcherImporter.importTypeMenu, UserAgentSwitcherImporter.getUserAgentFileLocation(), true); | |
1429 | UserAgentSwitcher.initializeDisplay(); | |
1430 | - | |
1431 | + | |
1432 | // If the observer service is set | |
1433 | if(observerService) | |
1434 | { | |
1435 | observerService.addObserver(UserAgentSwitcher, "quit-application-requested", false); | |
1436 | } | |
1437 | - | |
1438 | + | |
1439 | document.getElementById("navigator-toolbox").addEventListener("dragdrop", UserAgentSwitcher.buttonDrop, false); | |
1440 | window.removeEventListener("load", UserAgentSwitcher.initialize, false); | |
1441 | } | |
1442 | @@ -169,24 +169,25 @@ | |
1443 | { | |
1444 | UserAgentSwitcher.resetUserAgent(allWindows[i].document, defaultUserAgent); | |
1445 | } | |
1446 | - } | |
1447 | + } | |
1448 | }, | |
1449 | ||
1450 | // Returns true if this is the selected user agent | |
1451 | isSelectedUserAgent: function(userAgent) | |
1452 | { | |
1453 | // If all the attributes match | |
1454 | - if((UserAgentSwitcherPreferences.getStringPreference("general.useragent.appName", true) == userAgent.getAttribute("useragentswitcherappcodename") || (UserAgentSwitcherPreferences.getStringPreference("general.useragent.appName", true) == " " && userAgent.getAttribute("useragentswitcherappcodename") == "")) && | |
1455 | + if((UserAgentSwitcherPreferences.getStringPreference("general.useragent.appName", true) == userAgent.getAttribute("useragentswitcherappcodename") || (UserAgentSwitcherPreferences.getStringPreference("general.useragent.appName", true) == " " && userAgent.getAttribute("useragentswitcherappcodename") == "")) && | |
1456 | UserAgentSwitcherPreferences.getStringPreference("general.appname.override", true) == userAgent.getAttribute("useragentswitcherappname") && | |
1457 | UserAgentSwitcherPreferences.getStringPreference("general.appversion.override", true) == userAgent.getAttribute("useragentswitcherappversion") && | |
1458 | UserAgentSwitcherPreferences.getStringPreference("general.platform.override", true) == userAgent.getAttribute("useragentswitcherplatform") && | |
1459 | + UserAgentSwitcherPreferences.getStringPreference("general.oscpu.override", true) == userAgent.getAttribute("useragentswitcheroscpu") && | |
1460 | UserAgentSwitcherPreferences.getStringPreference("general.useragent.override", true) == userAgent.getAttribute("useragentswitcheruseragent") && | |
1461 | UserAgentSwitcherPreferences.getStringPreference("general.useragent.vendor", true) == userAgent.getAttribute("useragentswitchervendor") && | |
1462 | UserAgentSwitcherPreferences.getStringPreference("general.useragent.vendorSub", true) == userAgent.getAttribute("useragentswitchervendorsub")) | |
1463 | { | |
1464 | return true; | |
1465 | } | |
1466 | - | |
1467 | + | |
1468 | return false; | |
1469 | }, | |
1470 | ||
1471 | @@ -201,18 +202,18 @@ | |
1472 | ||
1473 | return false; | |
1474 | }, | |
1475 | - | |
1476 | + | |
1477 | // Called when a button has been dropped | |
1478 | - onDrop: function (event, transferData, session) | |
1479 | + onDrop: function (event, transferData, session) | |
1480 | { | |
1481 | // If the User Agent Switcher button was dropped | |
1482 | if(transferData.data == "useragentswitcher-button") | |
1483 | { | |
1484 | UserAgentSwitcherImporter.import(UserAgentSwitcherImporter.importTypeMenu, UserAgentSwitcherImporter.getUserAgentFileLocation(), true); | |
1485 | - UserAgentSwitcher.initializeDisplay(); | |
1486 | + UserAgentSwitcher.initializeDisplay(); | |
1487 | } | |
1488 | }, | |
1489 | - | |
1490 | + | |
1491 | // Opens a toolbar button automatically if another toolbar button is open on the toolbar | |
1492 | openToolbarButton: function(currentToolbarButton) | |
1493 | { | |
1494 | @@ -222,32 +223,32 @@ | |
1495 | var toolbarButton = null; | |
1496 | var toolbarButtons = currentToolbarButton.parentNode.getElementsByTagName("toolbarbutton"); | |
1497 | var toolbarButtonsLength = toolbarButtons.length; | |
1498 | - | |
1499 | + | |
1500 | // Loop through the toolbar buttons | |
1501 | for(var i = 0; i < toolbarButtonsLength; i++) | |
1502 | { | |
1503 | toolbarButton = toolbarButtons.item(i); | |
1504 | - | |
1505 | + | |
1506 | // If the toolbar button is set, is not the same toolbar button and is open | |
1507 | if(toolbarButton && toolbarButton != currentToolbarButton && toolbarButton.open) | |
1508 | { | |
1509 | toolbarButton.open = false; | |
1510 | currentToolbarButton.open = true; | |
1511 | - | |
1512 | + | |
1513 | break; | |
1514 | } | |
1515 | } | |
1516 | } | |
1517 | }, | |
1518 | - | |
1519 | + | |
1520 | // Displays the options dialog | |
1521 | options: function() | |
1522 | { | |
1523 | window.openDialog("chrome://useragentswitcher/content/options/options.xul", "useragentswitcher-options-dialog", "centerscreen,chrome,modal,resizable"); | |
1524 | - | |
1525 | + | |
1526 | UserAgentSwitcher.changeOptions(); | |
1527 | }, | |
1528 | - | |
1529 | + | |
1530 | // Resets the user agent | |
1531 | reset: function() | |
1532 | { | |
1533 | @@ -260,37 +261,44 @@ | |
1534 | { | |
1535 | UserAgentSwitcherPreferences.deletePreference("general.useragent.appName"); | |
1536 | } | |
1537 | - | |
1538 | + | |
1539 | // If an override app name is set | |
1540 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.appname.override")) | |
1541 | { | |
1542 | UserAgentSwitcherPreferences.deletePreference("general.appname.override"); | |
1543 | } | |
1544 | - | |
1545 | + | |
1546 | // If an override app version is set | |
1547 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.appversion.override")) | |
1548 | { | |
1549 | UserAgentSwitcherPreferences.deletePreference("general.appversion.override"); | |
1550 | } | |
1551 | - | |
1552 | + | |
1553 | // If an override platform is set | |
1554 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.platform.override")) | |
1555 | { | |
1556 | UserAgentSwitcherPreferences.deletePreference("general.platform.override"); | |
1557 | } | |
1558 | - | |
1559 | + | |
1560 | + // PROFEDIT: If an override oscpu is set | |
1561 | + if(UserAgentSwitcherPreferences.isPreferenceSet("general.oscpu.override")) | |
1562 | + { | |
1563 | + UserAgentSwitcherPreferences.deletePreference("general.oscpu.override"); | |
1564 | + } | |
1565 | + // ENDPROFEDIT | |
1566 | + | |
1567 | // If an override user agent is set | |
1568 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.override")) | |
1569 | { | |
1570 | UserAgentSwitcherPreferences.deletePreference("general.useragent.override"); | |
1571 | } | |
1572 | - | |
1573 | + | |
1574 | // If an override vendor is set | |
1575 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.vendor")) | |
1576 | { | |
1577 | UserAgentSwitcherPreferences.deletePreference("general.useragent.vendor"); | |
1578 | } | |
1579 | - | |
1580 | + | |
1581 | // If an override vendor sub is set | |
1582 | if(UserAgentSwitcherPreferences.isPreferenceSet("general.useragent.vendorSub")) | |
1583 | { | |
1584 | @@ -324,22 +332,22 @@ | |
1585 | ||
1586 | // If the user agent button is set | |
1587 | if(userAgentButton) | |
1588 | - { | |
1589 | + { | |
1590 | // If the user agent button has a default attribute | |
1591 | if(userAgentButton.hasAttribute("default")) | |
1592 | { | |
1593 | userAgentButton.removeAttribute("default"); | |
1594 | - } | |
1595 | + } | |
1596 | ||
1597 | userAgentButton.setAttribute("label", defaultUserAgent); | |
1598 | userAgentButton.setAttribute("tooltiptext", defaultUserAgent); | |
1599 | } | |
1600 | - | |
1601 | + | |
1602 | // Loop through the selected user agents | |
1603 | for(var i = 0; i < selectedUserAgentsLength; i++) | |
1604 | { | |
1605 | selectedUserAgent = selectedUserAgents[i]; | |
1606 | - | |
1607 | + | |
1608 | // If the selected user agent does not have an id or the id is not the default | |
1609 | if(!selectedUserAgent.hasAttribute("id") || selectedUserAgent.getAttribute("id").indexOf("useragentswitcher-default-") != 0) | |
1610 | { | |
1611 | @@ -376,7 +384,7 @@ | |
1612 | { | |
1613 | userAgentMenu.setAttribute("image", "chrome://useragentswitcher/skin/non-default.png"); | |
1614 | ||
1615 | - // If the selected user agent description is set | |
1616 | + // If the selected user agent description is set | |
1617 | if(selectedUserAgentDescription) | |
1618 | { | |
1619 | userAgentMenu.setAttribute("label", selectedUserAgentDescription); | |
1620 | @@ -385,22 +393,22 @@ | |
1621 | ||
1622 | // If the user agent button is set | |
1623 | if(userAgentButton) | |
1624 | - { | |
1625 | + { | |
1626 | userAgentButton.setAttribute("default", "false"); | |
1627 | ||
1628 | - // If the selected user agent description is set | |
1629 | + // If the selected user agent description is set | |
1630 | if(selectedUserAgentDescription) | |
1631 | { | |
1632 | userAgentButton.setAttribute("label", selectedUserAgentDescription); | |
1633 | userAgentButton.setAttribute("tooltiptext", selectedUserAgentDescription); | |
1634 | } | |
1635 | } | |
1636 | - | |
1637 | + | |
1638 | // Loop through the selected user agents | |
1639 | for(var i = 0; i < selectedUserAgentsLength; i++) | |
1640 | { | |
1641 | selectedUserAgent = selectedUserAgents[i]; | |
1642 | - | |
1643 | + | |
1644 | // If the selected user agent does not have an id or the id does not match the position | |
1645 | if(!selectedUserAgent.hasAttribute("id") || selectedUserAgent.getAttribute("id").indexOf("useragentswitcher-user-agent-" + position + "-") != 0) | |
1646 | { | |
1647 | @@ -420,7 +428,7 @@ | |
1648 | positionToolbar.setAttribute("checked", true); | |
1649 | } | |
1650 | }, | |
1651 | - | |
1652 | + | |
1653 | // Switches the user agent | |
1654 | switchUserAgent: function(userAgent) | |
1655 | { | |
1656 | @@ -429,17 +437,18 @@ | |
1657 | var appCodeName = userAgent.getAttribute("useragentswitcherappcodename"); | |
1658 | var position = userAgent.getAttribute("useragentswitcherposition"); | |
1659 | var userAgentDescription = userAgent.getAttribute("label"); | |
1660 | - | |
1661 | + | |
1662 | // If the app code name is not set add a space since an empty app code name is ignored | |
1663 | if(!appCodeName) | |
1664 | { | |
1665 | appCodeName = " "; | |
1666 | } | |
1667 | - | |
1668 | + | |
1669 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.appName", appCodeName); | |
1670 | UserAgentSwitcherPreferences.setStringPreference("general.appname.override", userAgent.getAttribute("useragentswitcherappname")); | |
1671 | UserAgentSwitcherPreferences.setStringPreference("general.appversion.override", userAgent.getAttribute("useragentswitcherappversion")); | |
1672 | UserAgentSwitcherPreferences.setStringPreference("general.platform.override", userAgent.getAttribute("useragentswitcherplatform")); | |
1673 | + UserAgentSwitcherPreferences.setStringPreference("general.oscpu.override", userAgent.getAttribute("useragentswitcheroscpu")); | |
1674 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.override", userAgent.getAttribute("useragentswitcheruseragent")); | |
1675 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.vendor", userAgent.getAttribute("useragentswitchervendor")); | |
1676 | UserAgentSwitcherPreferences.setStringPreference("general.useragent.vendorSub", userAgent.getAttribute("useragentswitchervendorsub")); | |
1677 | @@ -450,13 +459,13 @@ | |
1678 | UserAgentSwitcher.selectUserAgent(allWindows[i].document, position, userAgentDescription); | |
1679 | } | |
1680 | }, | |
1681 | - | |
1682 | + | |
1683 | // Opens the test page | |
1684 | test: function() | |
1685 | { | |
1686 | window.getBrowser().selectedTab = window.getBrowser().addTab("http://chrispederick.com/work/user-agent-switcher/features/test/"); | |
1687 | }, | |
1688 | - | |
1689 | + | |
1690 | // Uninitializes the extension | |
1691 | uninitialize: function(event) | |
1692 | { | |
1693 | @@ -464,27 +473,27 @@ | |
1694 | try | |
1695 | { | |
1696 | var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); | |
1697 | - | |
1698 | + | |
1699 | // If the observer service is set | |
1700 | if(observerService) | |
1701 | { | |
1702 | observerService.removeObserver(UserAgentSwitcher, "quit-application-requested", false); | |
1703 | } | |
1704 | - | |
1705 | + | |
1706 | // If the reset on close preference is not set or is set to true | |
1707 | if(!UserAgentSwitcherPreferences.isPreferenceSet("useragentswitcher.reset.onclose") || UserAgentSwitcherPreferences.getBooleanPreference("useragentswitcher.reset.onclose", true)) | |
1708 | { | |
1709 | var allWindows = UserAgentSwitcherDOM.getAllWindows(); | |
1710 | var windowCount = allWindows.length; | |
1711 | - | |
1712 | + | |
1713 | // If this is the last window closing | |
1714 | if(windowCount == 0) | |
1715 | { | |
1716 | UserAgentSwitcher.reset(); | |
1717 | } | |
1718 | } | |
1719 | - | |
1720 | - document.getElementById("navigator-toolbox").removeEventListener("dragdrop", UserAgentSwitcher.buttonDrop, false); | |
1721 | + | |
1722 | + document.getElementById("navigator-toolbox").removeEventListener("dragdrop", UserAgentSwitcher.buttonDrop, false); | |
1723 | window.removeEventListener("close", UserAgentSwitcher.uninitialize, false); | |
1724 | } | |
1725 | catch(exception) | |
1726 | diff -rU3 original/chrome/content/useragentswitcher/xml/export.js profexer/chrome/content/useragentswitcher/xml/export.js | |
1727 | --- original/chrome/content/useragentswitcher/xml/export.js 2011-01-04 18:53:34.000000000 +0200 | |
1728 | +++ profexer/chrome/content/useragentswitcher/xml/export.js 2012-06-16 00:05:00.000000000 +0300 | |
1729 | @@ -12,7 +12,7 @@ | |
1730 | { | |
1731 | file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 00644); | |
1732 | } | |
1733 | - | |
1734 | + | |
1735 | // If the file exists, is a file and is writable | |
1736 | if(file.exists() && file.isFile() && file.isWritable()) | |
1737 | { | |
1738 | @@ -21,9 +21,9 @@ | |
1739 | var xmlDocument = document.implementation.createDocument("", "", null); | |
1740 | var rootElement = xmlDocument.createElement("useragentswitcher"); | |
1741 | var xmlSerializer = new XMLSerializer(); | |
1742 | - | |
1743 | + | |
1744 | this.exportFile(document.getElementById("useragentswitcher-options-user-agents").childNodes, rootElement, xmlDocument); | |
1745 | - | |
1746 | + | |
1747 | xmlDocument.appendChild(rootElement); | |
1748 | ||
1749 | outputStream.init(file, 0x04 | 0x08 | 0x20, 00644, null); | |
1750 | @@ -39,7 +39,7 @@ | |
1751 | { | |
1752 | UserAgentSwitcherLog.log("UserAgentSwitcherExporter.export", exception); | |
1753 | } | |
1754 | - | |
1755 | + | |
1756 | return null; | |
1757 | }, | |
1758 | ||
1759 | @@ -52,7 +52,7 @@ | |
1760 | for(var i = 0; i < elementsLength; i++) | |
1761 | { | |
1762 | var element = elements[i]; | |
1763 | - | |
1764 | + | |
1765 | // If the element is a separator | |
1766 | if(element.nodeName == "treeseparator") | |
1767 | { | |
1768 | @@ -68,7 +68,7 @@ | |
1769 | } | |
1770 | } | |
1771 | }, | |
1772 | - | |
1773 | + | |
1774 | // Exports a folder | |
1775 | exportFolder: function(element, parentElement, xmlDocument) | |
1776 | { | |
1777 | @@ -82,7 +82,7 @@ | |
1778 | } | |
1779 | ||
1780 | this.exportFile(element.getElementsByTagName("treechildren")[0].childNodes, folder, xmlDocument); | |
1781 | - | |
1782 | + | |
1783 | parentElement.appendChild(folder); | |
1784 | }, | |
1785 | ||
1786 | @@ -91,12 +91,12 @@ | |
1787 | { | |
1788 | parentElement.appendChild(xmlDocument.createElement("separator")); | |
1789 | }, | |
1790 | - | |
1791 | + | |
1792 | // Exports a user agent | |
1793 | exportUserAgent: function(element, parentElement, xmlDocument) | |
1794 | { | |
1795 | var userAgentElement = element.getElementsByTagName("treerow")[0].getElementsByTagName("treecell")[0]; | |
1796 | - | |
1797 | + | |
1798 | // If the user agent has a label | |
1799 | if(userAgentElement.hasAttribute("label")) | |
1800 | { | |
1801 | @@ -113,7 +113,7 @@ | |
1802 | { | |
1803 | userAgent.setAttribute("useragent", ""); | |
1804 | } | |
1805 | - | |
1806 | + | |
1807 | // If the app code name is set | |
1808 | if(userAgentElement.hasAttribute("useragentswitcherappcodename")) | |
1809 | { | |
1810 | @@ -123,7 +123,7 @@ | |
1811 | { | |
1812 | userAgent.setAttribute("appcodename", ""); | |
1813 | } | |
1814 | - | |
1815 | + | |
1816 | // If the app name is set | |
1817 | if(userAgentElement.hasAttribute("useragentswitcherappname")) | |
1818 | { | |
1819 | @@ -133,7 +133,7 @@ | |
1820 | { | |
1821 | userAgent.setAttribute("appname", ""); | |
1822 | } | |
1823 | - | |
1824 | + | |
1825 | // If the app version is set | |
1826 | if(userAgentElement.hasAttribute("useragentswitcherappversion")) | |
1827 | { | |
1828 | @@ -143,7 +143,7 @@ | |
1829 | { | |
1830 | userAgent.setAttribute("appversion", ""); | |
1831 | } | |
1832 | - | |
1833 | + | |
1834 | // If the platform is set | |
1835 | if(userAgentElement.hasAttribute("useragentswitcherplatform")) | |
1836 | { | |
1837 | @@ -153,7 +153,18 @@ | |
1838 | { | |
1839 | userAgent.setAttribute("platform", ""); | |
1840 | } | |
1841 | - | |
1842 | + | |
1843 | + // PROFEDIT: If the oscpu is set | |
1844 | + if(userAgentElement.hasAttribute("useragentswitcheroscpu")) | |
1845 | + { | |
1846 | + userAgent.setAttribute("oscpu", userAgentElement.getAttribute("useragentswitcheroscpu")); | |
1847 | + } | |
1848 | + else | |
1849 | + { | |
1850 | + userAgent.setAttribute("oscpu", ""); | |
1851 | + } | |
1852 | + // ENDPROFEDIT | |
1853 | + | |
1854 | // If the vendor is set | |
1855 | if(userAgentElement.hasAttribute("useragentswitchervendor")) | |
1856 | { | |
1857 | @@ -163,7 +174,7 @@ | |
1858 | { | |
1859 | userAgent.setAttribute("vendor", ""); | |
1860 | } | |
1861 | - | |
1862 | + | |
1863 | // If the vendor sub is set | |
1864 | if(userAgentElement.hasAttribute("useragentswitchervendorsub")) | |
1865 | { | |
1866 | @@ -173,7 +184,7 @@ | |
1867 | { | |
1868 | userAgent.setAttribute("vendorsub", ""); | |
1869 | } | |
1870 | - | |
1871 | + | |
1872 | parentElement.appendChild(userAgent); | |
1873 | } | |
1874 | }, | |
1875 | diff -rU3 original/chrome/content/useragentswitcher/xml/import.js profexer/chrome/content/useragentswitcher/xml/import.js | |
1876 | --- original/chrome/content/useragentswitcher/xml/import.js 2011-01-04 18:53:34.000000000 +0200 | |
1877 | +++ profexer/chrome/content/useragentswitcher/xml/import.js 2012-06-16 00:05:42.000000000 +0300 | |
1878 | @@ -4,11 +4,11 @@ | |
1879 | importType: 0, | |
1880 | importTypeMenu: 1, | |
1881 | importTypeOptions: 2, | |
1882 | - | |
1883 | + | |
1884 | folderCount: 0, | |
1885 | separatorCount: 0, | |
1886 | userAgentCount: 0, | |
1887 | - | |
1888 | + | |
1889 | menuParentFolder: null, | |
1890 | optionsParentFolder: null, | |
1891 | toolbarParentFolder: null, | |
1892 | @@ -31,14 +31,14 @@ | |
1893 | { | |
1894 | var menu = this.importDocument.getElementById("useragentswitcher-popup-" + suffix); | |
1895 | var optionsSeparator = this.importDocument.getElementById("useragentswitcher-separator-2-" + suffix); | |
1896 | - | |
1897 | + | |
1898 | // If the menu and options separator exist | |
1899 | if(menu && optionsSeparator) | |
1900 | - { | |
1901 | + { | |
1902 | menu.insertBefore(newMenu, optionsSeparator); | |
1903 | - } | |
1904 | + } | |
1905 | } | |
1906 | - | |
1907 | + | |
1908 | return newMenu; | |
1909 | }, | |
1910 | ||
1911 | @@ -58,12 +58,12 @@ | |
1912 | { | |
1913 | var menu = this.importDocument.getElementById("useragentswitcher-popup-" + suffix); | |
1914 | var optionsSeparator = this.importDocument.getElementById("useragentswitcher-separator-2-" + suffix); | |
1915 | - | |
1916 | + | |
1917 | // If the menu and options separator exist | |
1918 | if(menu && optionsSeparator) | |
1919 | - { | |
1920 | + { | |
1921 | menu.insertBefore(newMenuSeparator, optionsSeparator); | |
1922 | - } | |
1923 | + } | |
1924 | } | |
1925 | }, | |
1926 | ||
1927 | @@ -73,7 +73,7 @@ | |
1928 | var newMenuItem = menuItem.cloneNode(false); | |
1929 | ||
1930 | newMenuItem.setAttribute("id", "useragentswitcher-user-agent-" + this.userAgentCount + "-" + suffix); | |
1931 | - newMenuItem.setAttribute("name", "useragentswitcher-group-" + suffix); | |
1932 | + newMenuItem.setAttribute("name", "useragentswitcher-group-" + suffix); | |
1933 | ||
1934 | // If the parent folder is set | |
1935 | if(parentFolder) | |
1936 | @@ -84,12 +84,12 @@ | |
1937 | { | |
1938 | var menu = this.importDocument.getElementById("useragentswitcher-popup-" + suffix); | |
1939 | var optionsSeparator = this.importDocument.getElementById("useragentswitcher-separator-2-" + suffix); | |
1940 | - | |
1941 | + | |
1942 | // If the menu and options separator exist | |
1943 | if(menu && optionsSeparator) | |
1944 | - { | |
1945 | + { | |
1946 | menu.insertBefore(newMenuItem, optionsSeparator); | |
1947 | - } | |
1948 | + } | |
1949 | } | |
1950 | }, | |
1951 | ||
1952 | @@ -139,7 +139,7 @@ | |
1953 | createUserAgentDirectory: function() | |
1954 | { | |
1955 | var userAgentDirectory = this.getUserAgentDirectoryLocation(); | |
1956 | - | |
1957 | + | |
1958 | userAgentDirectory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); | |
1959 | }, | |
1960 | ||
1961 | @@ -150,7 +150,7 @@ | |
1962 | ||
1963 | userAgentFile.initWithPath(this.getUserAgentFileLocation().path); | |
1964 | userAgentFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 00644); | |
1965 | - | |
1966 | + | |
1967 | return userAgentFile; | |
1968 | }, | |
1969 | ||
1970 | @@ -163,15 +163,15 @@ | |
1971 | var ownerDocument = element.ownerDocument; | |
1972 | var xPathEvaluator = new XPathEvaluator(); | |
1973 | var resolver = xPathEvaluator.createNSResolver(element.ownerDocument == null ? element.documentElement : element.ownerDocument.documentElement); | |
1974 | - | |
1975 | + | |
1976 | evaluationResults = xPathEvaluator.evaluate(expression, element, resolver, 0, null); | |
1977 | - | |
1978 | + | |
1979 | // While there are more matching elements | |
1980 | while((matchingElement = evaluationResults.iterateNext()) != null) | |
1981 | { | |
1982 | matchingElements.push(matchingElement); | |
1983 | } | |
1984 | - | |
1985 | + | |
1986 | return matchingElements; | |
1987 | }, | |
1988 | ||
1989 | @@ -180,11 +180,11 @@ | |
1990 | { | |
1991 | var existingCounts = {}; | |
1992 | var userAgentTree = this.importDocument.getElementById("useragentswitcher-options-user-agents"); | |
1993 | - | |
1994 | + | |
1995 | existingCounts.folderCount = UserAgentSwitcherDOM.findElementsByXPath(userAgentTree, "//treeitem[@container='true']").length; | |
1996 | existingCounts.separatorCount = UserAgentSwitcherDOM.findElementsByXPath(userAgentTree, "//treeseparator").length; | |
1997 | existingCounts.userAgentCount = UserAgentSwitcherDOM.findElementsByXPath(userAgentTree, "//treeitem[not(@container)]").length; | |
1998 | - | |
1999 | + | |
2000 | return existingCounts; | |
2001 | }, | |
2002 | ||
2003 | @@ -194,7 +194,7 @@ | |
2004 | var directory = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsILocalFile); | |
2005 | ||
2006 | directory.append("useragentswitcher"); | |
2007 | - | |
2008 | + | |
2009 | return directory; | |
2010 | }, | |
2011 | ||
2012 | @@ -202,9 +202,9 @@ | |
2013 | getUserAgentFileLocation: function() | |
2014 | { | |
2015 | var file = this.getUserAgentDirectoryLocation(); | |
2016 | - | |
2017 | + | |
2018 | file.append("useragents.xml"); | |
2019 | - | |
2020 | + | |
2021 | return file; | |
2022 | }, | |
2023 | ||
2024 | @@ -219,12 +219,12 @@ | |
2025 | { | |
2026 | var request = new XMLHttpRequest(); | |
2027 | var xmlDocument = null; | |
2028 | - | |
2029 | + | |
2030 | request.open("get", "file://" + file.path, false); | |
2031 | request.send(null); | |
2032 | - | |
2033 | + | |
2034 | xmlDocument = request.responseXML; | |
2035 | - | |
2036 | + | |
2037 | // If the file could not be parsed correctly | |
2038 | if(xmlDocument.documentElement.nodeName == "parsererror") | |
2039 | { | |
2040 | @@ -242,16 +242,16 @@ | |
2041 | if(type == this.importTypeOptions) | |
2042 | { | |
2043 | this.importDocument = document; | |
2044 | - | |
2045 | + | |
2046 | // If the overwrite preference is set | |
2047 | if(this.importDocument.getElementById("useragentswitcher-import-overwrite").checked) | |
2048 | { | |
2049 | - UserAgentSwitcherDOM.removeAllChildElements(this.importDocument.getElementById("useragentswitcher-options-user-agents")); | |
2050 | + UserAgentSwitcherDOM.removeAllChildElements(this.importDocument.getElementById("useragentswitcher-options-user-agents")); | |
2051 | } | |
2052 | else | |
2053 | { | |
2054 | var existingCounts = this.getExistingCounts(); | |
2055 | - | |
2056 | + | |
2057 | this.folderCount = existingCounts.folderCount; | |
2058 | this.separatorCount = existingCounts.separatorCount; | |
2059 | this.userAgentCount = existingCounts.userAgentCount; | |
2060 | @@ -260,11 +260,11 @@ | |
2061 | else | |
2062 | { | |
2063 | this.setImportDocument(ignoreParentWindow); | |
2064 | - this.removeUserAgents(); | |
2065 | + this.removeUserAgents(); | |
2066 | } | |
2067 | - | |
2068 | + | |
2069 | this.importFile(xmlDocument.documentElement); | |
2070 | - | |
2071 | + | |
2072 | // If nothing was imported | |
2073 | if(this.separatorCount == 0 && this.folderCount == 0 && this.userAgentCount == 0) | |
2074 | { | |
2075 | @@ -284,7 +284,7 @@ | |
2076 | ||
2077 | return null; | |
2078 | }, | |
2079 | - | |
2080 | + | |
2081 | // Imports the user agents | |
2082 | importFile: function(rootNode) | |
2083 | { | |
2084 | @@ -302,23 +302,23 @@ | |
2085 | { | |
2086 | this.userAgentCount++; | |
2087 | ||
2088 | - this.importUserAgent(element); | |
2089 | + this.importUserAgent(element); | |
2090 | } | |
2091 | else if(element.nodeName == "folder") | |
2092 | { | |
2093 | - this.folderCount++; | |
2094 | + this.folderCount++; | |
2095 | ||
2096 | - this.importFolder(element); | |
2097 | + this.importFolder(element); | |
2098 | } | |
2099 | else if(element.nodeName == "separator") | |
2100 | { | |
2101 | this.separatorCount++; | |
2102 | ||
2103 | - this.importSeparator(); | |
2104 | + this.importSeparator(); | |
2105 | } | |
2106 | } | |
2107 | }, | |
2108 | - | |
2109 | + | |
2110 | // Imports a folder | |
2111 | importFolder: function(folderElement) | |
2112 | { | |
2113 | @@ -328,22 +328,22 @@ | |
2114 | var menu = this.importDocument.createElement("menu"); | |
2115 | var previousMenuParentFolder = this.menuParentFolder; | |
2116 | var previousToolbarParentFolder = this.toolbarParentFolder; | |
2117 | - | |
2118 | + | |
2119 | // If the folder element has a description attribute | |
2120 | if(folderElement.hasAttribute("description")) | |
2121 | { | |
2122 | menu.setAttribute("label", folderElement.getAttribute("description")); | |
2123 | } | |
2124 | - | |
2125 | + | |
2126 | menu.appendChild(this.importDocument.createElement("menupopup")); | |
2127 | - | |
2128 | - this.menuParentFolder = this.addMenuFolder(menu, "menu", this.menuParentFolder); | |
2129 | - this.toolbarParentFolder = this.addMenuFolder(menu, "toolbar", this.toolbarParentFolder); | |
2130 | - | |
2131 | + | |
2132 | + this.menuParentFolder = this.addMenuFolder(menu, "menu", this.menuParentFolder); | |
2133 | + this.toolbarParentFolder = this.addMenuFolder(menu, "toolbar", this.toolbarParentFolder); | |
2134 | + | |
2135 | this.importFile(folderElement); | |
2136 | - | |
2137 | - this.menuParentFolder = previousMenuParentFolder; | |
2138 | - this.toolbarParentFolder = previousToolbarParentFolder; | |
2139 | + | |
2140 | + this.menuParentFolder = previousMenuParentFolder; | |
2141 | + this.toolbarParentFolder = previousToolbarParentFolder; | |
2142 | } | |
2143 | else if(this.importType == this.importTypeOptions) | |
2144 | { | |
2145 | @@ -352,7 +352,7 @@ | |
2146 | var treeChildren = this.importDocument.createElement("treechildren"); | |
2147 | var treeItem = this.importDocument.createElement("treeitem"); | |
2148 | var treeRow = this.importDocument.createElement("treerow"); | |
2149 | - | |
2150 | + | |
2151 | // If the folder element has a description attribute | |
2152 | if(folderElement.hasAttribute("description")) | |
2153 | { | |
2154 | @@ -364,17 +364,17 @@ | |
2155 | treeRow.appendChild(treeCell); | |
2156 | treeItem.appendChild(treeRow); | |
2157 | treeItem.appendChild(treeChildren); | |
2158 | - | |
2159 | - this.addOptionsFolder(treeItem); | |
2160 | - | |
2161 | + | |
2162 | + this.addOptionsFolder(treeItem); | |
2163 | + | |
2164 | this.optionsParentFolder = treeChildren; | |
2165 | - | |
2166 | + | |
2167 | this.importFile(folderElement); | |
2168 | - | |
2169 | + | |
2170 | this.optionsParentFolder = previousParentFolder | |
2171 | } | |
2172 | }, | |
2173 | - | |
2174 | + | |
2175 | // Imports a separator | |
2176 | importSeparator: function() | |
2177 | { | |
2178 | @@ -382,16 +382,16 @@ | |
2179 | if(this.importType == this.importTypeMenu) | |
2180 | { | |
2181 | var menuSeparator = this.importDocument.createElement("menuseparator"); | |
2182 | - | |
2183 | - this.addMenuSeparator(menuSeparator, "menu", this.menuParentFolder); | |
2184 | - this.addMenuSeparator(menuSeparator, "toolbar", this.toolbarParentFolder); | |
2185 | + | |
2186 | + this.addMenuSeparator(menuSeparator, "menu", this.menuParentFolder); | |
2187 | + this.addMenuSeparator(menuSeparator, "toolbar", this.toolbarParentFolder); | |
2188 | } | |
2189 | else if(this.importType == this.importTypeOptions) | |
2190 | { | |
2191 | - this.addOptionsSeparator(this.importDocument.createElement("treeseparator")); | |
2192 | + this.addOptionsSeparator(this.importDocument.createElement("treeseparator")); | |
2193 | } | |
2194 | }, | |
2195 | - | |
2196 | + | |
2197 | // Imports a user agent | |
2198 | importUserAgent: function(userAgentElement) | |
2199 | { | |
2200 | @@ -402,32 +402,32 @@ | |
2201 | if(this.importType == this.importTypeMenu) | |
2202 | { | |
2203 | var menuItem = this.importDocument.createElement("menuitem"); | |
2204 | - | |
2205 | + | |
2206 | this.populateUserAgent(menuItem, userAgentElement); | |
2207 | - | |
2208 | + | |
2209 | menuItem.setAttribute("oncommand", "UserAgentSwitcher.switchUserAgent(this)"); | |
2210 | menuItem.setAttribute("type", "radio"); | |
2211 | menuItem.setAttribute("useragentswitcherposition", this.userAgentCount); | |
2212 | - | |
2213 | - this.addMenuUserAgent(menuItem, "menu", this.menuParentFolder); | |
2214 | - this.addMenuUserAgent(menuItem, "toolbar", this.toolbarParentFolder); | |
2215 | + | |
2216 | + this.addMenuUserAgent(menuItem, "menu", this.menuParentFolder); | |
2217 | + this.addMenuUserAgent(menuItem, "toolbar", this.toolbarParentFolder); | |
2218 | } | |
2219 | else if(this.importType == this.importTypeOptions) | |
2220 | { | |
2221 | var treeCell = this.importDocument.createElement("treecell"); | |
2222 | var treeItem = this.importDocument.createElement("treeitem"); | |
2223 | var treeRow = this.importDocument.createElement("treerow"); | |
2224 | - | |
2225 | + | |
2226 | this.populateUserAgent(treeCell, userAgentElement); | |
2227 | - | |
2228 | + | |
2229 | treeRow.appendChild(treeCell); | |
2230 | treeItem.appendChild(treeRow); | |
2231 | ||
2232 | - this.addOptionsUserAgent(treeItem); | |
2233 | + this.addOptionsUserAgent(treeItem); | |
2234 | } | |
2235 | } | |
2236 | }, | |
2237 | - | |
2238 | + | |
2239 | // Populates a user agent | |
2240 | populateUserAgent: function(userAgent, userAgentElement) | |
2241 | { | |
2242 | @@ -473,6 +473,17 @@ | |
2243 | userAgent.setAttribute("useragentswitcherplatform", ""); | |
2244 | } | |
2245 | ||
2246 | + // PROFEDIT: If the user agent element has a oscpu attribute | |
2247 | + if(userAgentElement.hasAttribute("oscpu")) | |
2248 | + { | |
2249 | + userAgent.setAttribute("useragentswitcheroscpu", userAgentElement.getAttribute("oscpu")); | |
2250 | + } | |
2251 | + else | |
2252 | + { | |
2253 | + userAgent.setAttribute("useragentswitcheroscpu", ""); | |
2254 | + } | |
2255 | + // ENDPROFEDIT | |
2256 | + | |
2257 | // If the user agent element has a useragent attribute | |
2258 | if(userAgentElement.hasAttribute("useragent")) | |
2259 | { | |
2260 | @@ -503,7 +514,7 @@ | |
2261 | userAgent.setAttribute("useragentswitchervendorsub", ""); | |
2262 | } | |
2263 | }, | |
2264 | - | |
2265 | + | |
2266 | // Removes the user agents from the menu | |
2267 | removeMenuUserAgents: function(suffix) | |
2268 | { | |
2269 | @@ -511,7 +522,7 @@ | |
2270 | ||
2271 | // If the options separator exists | |
2272 | if(optionsSeparator) | |
2273 | - { | |
2274 | + { | |
2275 | // Remove the next sibling to the top separator if it exists and is not the bottom separator | |
2276 | while(optionsSeparator.nextSibling && optionsSeparator.nextSibling.getAttribute("id") != "useragentswitcher-separator-2-" + suffix) | |
2277 | { | |
2278 | @@ -519,14 +530,14 @@ | |
2279 | } | |
2280 | } | |
2281 | }, | |
2282 | - | |
2283 | + | |
2284 | // Removes the user agents | |
2285 | removeUserAgents: function() | |
2286 | { | |
2287 | this.removeMenuUserAgents("menu"); | |
2288 | this.removeMenuUserAgents("toolbar"); | |
2289 | }, | |
2290 | - | |
2291 | + | |
2292 | // Resets the user agent file | |
2293 | reset: function() | |
2294 | { | |
2295 | @@ -541,14 +552,14 @@ | |
2296 | ||
2297 | outputStream.init(userAgentFile, 0x04 | 0x08 | 0x20, 00644, null); | |
2298 | outputStream.write(request.responseText, request.responseText.length); | |
2299 | - outputStream.close(); | |
2300 | + outputStream.close(); | |
2301 | }, | |
2302 | ||
2303 | // Sets the import document | |
2304 | setImportDocument: function(ignoreParentWindow) | |
2305 | { | |
2306 | this.importDocument = document; | |
2307 | - | |
2308 | + | |
2309 | // If not ignoring the parent window and there is a parent window | |
2310 | if(!ignoreParentWindow && window.opener) | |
2311 | { | |
2312 | diff -rU3 original/chrome/content/useragentswitcher/xml/useragents.xml profexer/chrome/content/useragentswitcher/xml/useragents.xml | |
2313 | --- original/chrome/content/useragentswitcher/xml/useragents.xml 2011-01-04 18:53:34.000000000 +0200 | |
2314 | +++ profexer/chrome/content/useragentswitcher/xml/useragents.xml 2012-06-16 00:28:37.000000000 +0300 | |
2315 | @@ -1,13 +1,13 @@ | |
2316 | <useragentswitcher> | |
2317 | <folder description="Internet Explorer"> | |
2318 | - <useragent description="Internet Explorer 6" useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 6.0; Windows NT 5.1)" platform="Win32" vendor="" vendorsub=""/> | |
2319 | - <useragent description="Internet Explorer 7" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 7.0; Windows NT 6.0)" platform="Win32" vendor="" vendorsub=""/> | |
2320 | - <useragent description="Internet Explorer 8" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 8.0; Windows NT 6.1)" platform="Win32" vendor="" vendorsub=""/> | |
2321 | + <useragent description="Internet Explorer 6" useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 6.0; Windows NT 5.1)" platform="Win32" oscpu="Windows NT 5.1" vendor="" vendorsub=""/> | |
2322 | + <useragent description="Internet Explorer 7" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 7.0; Windows NT 6.0)" platform="Win32" oscpu="Windows NT 6.0" vendor="" vendorsub=""/> | |
2323 | + <useragent description="Internet Explorer 8" useragent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)" appcodename="Mozilla" appname="Microsoft Internet Explorer" appversion="4.0 (compatible; MSIE 8.0; Windows NT 6.1)" platform="Win32" oscpu="Windows NT 6.1" vendor="" vendorsub=""/> | |
2324 | </folder> | |
2325 | <folder description="Search Robots"> | |
2326 | - <useragent description="Googlebot 2.1" useragent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/> | |
2327 | - <useragent description="Msnbot 1.1" useragent="msnbot/1.1 (+http://search.msn.com/msnbot.htm)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/> | |
2328 | - <useragent description="Yahoo Slurp" useragent="Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" appcodename="" appname="" appversion="" platform="" vendor="" vendorsub=""/> | |
2329 | + <useragent description="Googlebot 2.1" useragent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" appcodename="" appname="" appversion="" platform="" oscpu="" vendor="" vendorsub=""/> | |
2330 | + <useragent description="Msnbot 1.1" useragent="msnbot/1.1 (+http://search.msn.com/msnbot.htm)" appcodename="" appname="" appversion="" platform="" oscpu="" vendor="" vendorsub=""/> | |
2331 | + <useragent description="Yahoo Slurp" useragent="Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" appcodename="" appname="" appversion="" platform="" oscpu="" vendor="" vendorsub=""/> | |
2332 | </folder> | |
2333 | - <useragent description="iPhone 3.0" useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" appcodename="Mozilla" appname="Netscape" appversion="5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" platform="iPhone" vendor="Apple Computer, Inc." vendorsub=""/> | |
2334 | -</useragentswitcher> | |
2335 | \ No newline at end of file | |
2336 | + <useragent description="iPhone 3.0" useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" appcodename="Mozilla" appname="Netscape" appversion="5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" platform="iPhone" oscpu="iPhone" vendor="Apple Computer, Inc." vendorsub=""/> | |
2337 | +</useragentswitcher> | |
2338 | diff -rU3 original/chrome/locale/en-US/useragentswitcher/useragentswitcher.dtd profexer/chrome/locale/en-US/useragentswitcher/useragentswitcher.dtd | |
2339 | --- original/chrome/locale/en-US/useragentswitcher/useragentswitcher.dtd 2011-01-04 18:53:36.000000000 +0200 | |
2340 | +++ profexer/chrome/locale/en-US/useragentswitcher/useragentswitcher.dtd 2012-06-15 23:48:15.000000000 +0300 | |
2341 | @@ -40,6 +40,7 @@ | |
2342 | <!ENTITY useragentswitcher.options.title "User Agent Switcher Options"> | |
2343 | <!ENTITY useragentswitcher.paste "Paste"> | |
2344 | <!ENTITY useragentswitcher.platform "Platform:"> | |
2345 | +<!ENTITY useragentswitcher.oscpu "OSCPU:"> | |
2346 | <!ENTITY useragentswitcher.reset.options "Reset Options..."> | |
2347 | <!ENTITY useragentswitcher.test "Test..."> | |
2348 | <!ENTITY useragentswitcher.test.key "T"> | |
2349 | Binary files original/chrome/useragentswitcher.jar and profexer/chrome/useragentswitcher.jar differ | |
2350 | diff -rU3 original/install.js profexer/install.js | |
2351 | --- original/install.js 2011-01-04 18:53:36.000000000 +0200 | |
2352 | +++ profexer/install.js 2012-06-16 00:23:16.000000000 +0300 | |
2353 | @@ -1,6 +1,6 @@ | |
2354 | -var author = "Chris Pederick"; | |
2355 | +var author = "Created by: Chris Pederick, Edited by: Profexer"; | |
2356 | var contentFlag = CONTENT | PROFILE_CHROME; | |
2357 | -var displayName = "User Agent Switcher"; | |
2358 | +var displayName = "User Agent Switcher (Profexer edition)"; | |
2359 | var error = null; | |
2360 | var folder = getFolder("Current User", "chrome"); | |
2361 | var localeFlag = LOCALE | PROFILE_CHROME; | |
2362 | @@ -68,4 +68,4 @@ | |
2363 | { | |
2364 | alert("The installation of the " + displayName + " extension failed.\nThe error code is: " + error); | |
2365 | } | |
2366 | -} | |
2367 | \ No newline at end of file | |
2368 | +} | |
2369 | diff -rU3 original/install.rdf profexer/install.rdf | |
2370 | --- original/install.rdf 2011-01-04 18:53:36.000000000 +0200 | |
2371 | +++ profexer/install.rdf 2012-06-16 00:21:48.000000000 +0300 | |
2372 | @@ -4,16 +4,16 @@ | |
2373 | xmlns:em="http://www.mozilla.org/2004/em-rdf#"> | |
2374 | ||
2375 | <Description about="urn:mozilla:install-manifest"> | |
2376 | - <em:aboutURL>chrome://useragentswitcher/content/about/about.xul</em:aboutURL> | |
2377 | - <em:creator>Chris Pederick</em:creator> | |
2378 | + <!--<em:aboutURL>chrome://useragentswitcher/content/about/about.xul</em:aboutURL>--> | |
2379 | + <em:creator>Created by: Chris Pederick, Edited by: Profexer</em:creator> | |
2380 | <em:description>Adds a menu and a toolbar button to switch the user agent of a browser.</em:description> | |
2381 | - <em:homepageURL>http://chrispederick.com/work/user-agent-switcher/</em:homepageURL> | |
2382 | + <!--<em:homepageURL>http://chrispederick.com/work/user-agent-switcher/</em:homepageURL>--> | |
2383 | <em:iconURL>chrome://useragentswitcher/content/logo.png</em:iconURL> | |
2384 | <em:id>{e968fc70-8f95-4ab9-9e79-304de2a71ee1}</em:id> | |
2385 | - <em:name>User Agent Switcher</em:name> | |
2386 | + <em:name>User Agent Switcher (Profexer edition)</em:name> | |
2387 | <em:optionsURL>chrome://useragentswitcher/content/options/options.xul</em:optionsURL> | |
2388 | - <em:updateInfoURL>http://chrispederick.com/work/user-agent-switcher/history/</em:updateInfoURL> | |
2389 | - <em:version>0.7.3</em:version> | |
2390 | + <!--<em:updateInfoURL>http://chrispederick.com/work/user-agent-switcher/history/</em:updateInfoURL>--> | |
2391 | + <em:version>0.7.3 (PE)</em:version> | |
2392 | <em:file> | |
2393 | <Description about="urn:mozilla:extension:file:useragentswitcher.jar"> | |
2394 | <em:locale>locale/en-US/useragentswitcher/</em:locale> | |
2395 | @@ -44,10 +44,10 @@ | |
2396 | </em:targetApplication> | |
2397 | <em:targetApplication> | |
2398 | <Description> | |
2399 | - <em:id>songbird@songbirdnest.com</em:id> | |
2400 | + <!--<em:id>songbird@songbirdnest.com</em:id>--> | |
2401 | <em:maxVersion>1.8.*</em:maxVersion> | |
2402 | <em:minVersion>1.0</em:minVersion> | |
2403 | </Description> | |
2404 | </em:targetApplication> | |
2405 | </Description> | |
2406 | -</RDF> | |
2407 | \ No newline at end of file | |
2408 | +</RDF> | |
2409 | Only in original/: original.xpi | |
2410 | Only in profexer/: profexer.xpi |