Hacking firefox part 41

  • 10 trang
  • file .pdf
402 Part VI — Creating Extensions and Themes
 http://www.mozillazine.org
 http://www.gfxoasis.com
 http://www.neowin.net
All of these sites have dedicated Mozilla/Firefox theme forums for postings. After all, the more
people who know about the theme, the better.
Supporting Different Operating-System Platforms
One of the underlying goals of the Mozilla organization is cross-platform compatibility.
Unfortunately, there is a bug with themes. On themes using native scroll bars (meaning that
the scroll bars are drawn by the operating system rather than themed), the code is slightly dif-
ferent for the Mac operating systems than for all other operating systems. The default theme,
as well as all of my own themes, suffer from this bug. This means that you’ll have to maintain
two versions of your theme: one for Mac users and one for those who use Windows, Linux, and
all other operating systems that run Firefox. I submitted a bug to Bugzilla in October 2003 and
progress has been slow, but it finally looks like a solution may be near. Keep an eye out for
updates at https://bugzilla.mozilla.org/show_bug.cgi?id=222654 for the
most up-to-date information. For compatibility with all operating systems, I recommend mak-
ing both a Mac and a non-Mac version of your theme available to users until bug 222654 is
fixed.
There are quite a few differences between the two scrollbars.css files, so it is not feasible to list
the differences between them at this time. You can obtain a copy of both files by visiting
http://www.hackingfirefox.com/themes.
Hacking Existing Themes
If you wish to modify existing themes, you should be able to do that easily. Now that you know
the process for creating a theme from the default theme, modifying an existing theme will be
much easier. You don’t have to redefine the install.rdf and contents.rdf files, and the directory
structure will already be set up properly for you.
Using the method to extract the contents of the default jar file, do the same for the existing
theme you wish to hack. Then you can go ahead and modify images or attributes in CSS files
as you did when creating your theme. When you finish, you can re-create the JAR archive for
the existing theme. Then replace the unhacked version in your profile folder, using the method
I suggested. After you restart Firefox, your hacked version of the preexisting theme will load
instead of the unhacked version.
Chapter 18 — Creating Themes 403
Summary
This chapter covers the core topics for creating a Firefox theme. The chapter starts by defining
the necessary tools and then moves on to describe the procedure for using the default theme as
a base. Definition of core files, CSS, and image customizations are covered. Package and
deployment of your theme are discussed. Information for supporting multiple operating sys-
tems and to hack existing themes is also provided.
While this chapter covers the basics, there will be a lot of work on your own to customize the
graphics and CSS files to your liking.
Index
Numerics Amazon.com search plugin, 226–227
7-Zip compression tool, 43–44, 322, 382 anti-phishing measures and tools, 116
Apollo theme, 72
A appearance of web pages, 371–373
Aaron Spuler’s themes, 72–73 Apple QuickTime plugin, 219, 252
about:cache, 92 Atlas theme, 72, 79
about:config attributes
accessibility.typeaheadfind.timeout id, 327
hack, 237 list-style-image, 329
Download Manager, 200 sitestate, 327–328
editing, 18 tooltiptext, 327
mousewheel options, 192 xmlns, 327
opening, 17 audio, 54, 173
plugins, 217–218 autoinstallation, 114
Preference Name column, 17 automatic indentation (text editor), 322
preferences automating
filtering, 18 extension packaging, 375–376
finding, 18–19 Firefox installation, 244
Status column, 17 profile creation, 249–250
tabbed browsing, 185 Axialis IconWorkshop, 396
Type column, 17
Value column, 17 B
accessibility.typeaheadfind.timeout Babelfish translation engine, 230
hack, 237 background colors for browser window, 58–62
accessing older extensions, 34–35 background images
ad blocking browser window, 62–65
with Adblock extension, 127–134 finding, 63
with content handling, 123–126 Backup directory, 13
with image blocking function, 120–122 backup extensions
with popup blocking function, 119–120 Bookmark Backup, 277–278
Adblock extension, 53, 127–134 Bookmarks Synchronizer, 278–279
Adblock Project forum, 133 backups
addEventListener function, 360 files, 14–16
adding Mozbackup, 275–276
keyboard shortcuts, 368–369 Mozbackup tool, 14–15
search engines to search box, 225 plugins, 276–277
toolbar buttons, 162, 369–371 profiles, 14–16, 267–268, 274–275
toolbar items, 143 BBCode extension, 55, 292
toolbars, 369–370 BBCodeXtra extension, 292
Adobe Photoshop, 323 BBEdit text editor, 8
Adobe Photoshop Elements, 323 behavior of downloads
Adobe Reader plugin, 219 clearing download history, 198–201
Advanced Installer tool, 263–264 default download location, 197–198
alert() function, 342 MIME types, 209–212
All-in-One Gestures extension, 194–196 pausing, 203
Altavista’s Babelfish translation engine, 230 preferences, 201–202
Alt-Text for Link extension, 53 seamless download integration, 215–216
406 Index B–C■
behavior of downloads (continued) browser.cache.memory.capacity hack, 94
showing in status bar, 202 browser.dom.window.dump.enabled
sorting to directories, 208–209 preference, 342
target windows, 206–208 browser.xul.error_pages.enabled hack, 88
behavior of links, 183–184 browsing history
behavior of windows, 189 cache, 106
BitTorrent download manager, 214 clearing, 105–108
blocking deleting individual items, 108
advertisements Download Manager, 106–107
with Adblock extension, 127–134 locations of, 105
with content handling, 123–126 viewing individual items, 108
with image blocking function, 120–122 brushed metal background (themes), 73
with popup blocking function, 119–120 bubbling phase (event propagation), 358–359
cookies, 110–111 bugs in themes, 402
error dialogs, 88 Bugzilla website, 88
JavaScript, 134 builds
Blue theme, 72 BlueFyre builds, 98
BlueFyre builds, 98 branch builds, 98
blur event, 357 branch versions, 97
Bookmark Backup extension, 54, 277–278 Builds forum, 201
bookmarks milestone versions, 97
home pages, 181–182 MMOY builds, 98
ICON property, 78 MOOX builds, 98
icons, 77–79 optimized builds, 97–98
live bookmarks system icon, 159, 161–162 stipe builds, 98
Quick Searches, 224 test builds, 201
Toolbar Enhancements extension, 164–165 third-party builds, 96–98
Bookmarks Synchronizer extension, 278–279 trunk builds, 98, 201
bookmarks toolbar, 157–158 button element, 352
bookmarks.html file buttons (toolbars)
backup, 15, 274 adding, 162, 369–371
contents, 270 EMButtons extension, 51–52, 54, 163–164
box model scheme (XUL), 301 icons, 371
branch builds, 98 Mozilla Updates button, 162
branch versions of builds, 97 Toolbar Enhancements extension, 164–165
browser plugin, 316
browser settings C
error dialogs, 88 cache, 106
home page cache directory
multiple home pages, 180–183 clearing, 91
single home page, 179–180 profiles, 271
link behavior, 183–184 capturing phase (event propagation), 358
premature timeouts, 86 Cascading Style Sheets (CSS)
profile, 10 colors, 59
saving, 188 comments, 59
smooth scrolling, 88 defined, 307
browser window documentation, 25
background color, 58–62 font modifications, 147
background images, 62–65 resources, 309
browser.cache.disk.capacity hack, 92–93 rules, 308–309
browser.cache.disk.parent_directory hack, siteledsOverlay.css, 329
91–92 specification, 309
Index C
■ 407
standards, 25 comments
theme creation, 389 CSS (Cascading Style Sheets), 59
tutorials, 389 INI files, 247
XUL documents, 307–308 Compact Menu extension, 147–149
changing compatibility of extensions, 319
disk cache location, 91–92 compatibility.ini file, 270
disk space amount for disk cache, 92–93 components.ini file, 270
Master Password, 104 compreg.dat file, 270
checkbox element, 353–354 compression tools
checking installed plugins, 217–218 command-line interface, 323
Checky extension, 296 7-Zip, 43–44, 322, 382
Chinese language translation, 230 theme creation, 382
chrome WinRar, 245, 322
programming extensions, 346 WinZip, 322, 382
resources conditional statements ( JavaScript), 304
content, 325 config.ini file
defined, 324 comments, 247
locale, 325 contents, 247
skin, 325 editing, 247
themes, 387 Path parameter, 249
chrome directory, 271, 334 Run Mode parameter, 248
chrome manifest files Show Dialog parameter, 248
new-style, 339–340 structure, 247
old-style, 333–338 config.trim_on_minimize hack, 95
Chrome Registration Failed error dialog, 341 configuration INI file
chrome registry, 325 comments, 247
chrome URLs, 324–326 contents, 247
chromeEdit extension editing, 247
downloading, 8, 27 Path parameter, 249
editing environment, 27–28 Run Mode parameter, 248
features, 54 Show Dialog parameter, 248
classic.jar file, 383 structure, 247
cleaning up, 99–100 Configuration Mania extension
clearing Browser category, 282
browsing history, 105–108 Debug category, 283
cache directory, 91 functionality, 28–29, 54, 281
download history, 106–107, 198–201 HTTP Network category, 282
form data, 102 mouse scrolling, 193–194
login data, 102 configuring
settings, 201 plugins, 220
click event, 356 web server, 343–344
clock, 54, 170–171 connections
colors FTP server, 86, 279–280
CSS (Cascading Style Sheets), 59 performance testing, 88–90
hexadecimal codes, 59 web server
menus, 147 keep-alive, 85
tabs, 185 persistent connections, 85
ColorZilla extension, 289, 343 simultaneous connections, 84–85
command event, 356–357 Console extension, 8–9, 293
command-line interface content directory, 46–47, 334
compression tools, 323 content handling, 123–126
installer, 244 content resource (chrome), 325
408 Index C ■
content.interrupt.parsing hack, 87 tools, 381–382
content.maxtextrun hack, 87 update.rdf file, 399–400
content.max.tokenizing.time hack, 87 toolbars, 159
content.notify.backoffcount hack, 87 userChrome.css file, 143
content.notify.interval hack, 87 Windows desktop icons, 253
content.notify.ontimer hack, 87 Crimson Editor, 322
content.notify.threshold hack, 87 Cross Platform Component Object Model (XPCOM),
contents.rdf file, 335–337, 385–386 314–316
context menus, 366–368 CSS (Cascading Style Sheets)
context menus (toolbars), 157 colors, 59
Context Search extension, 227 comments, 59
converting ICO files to PNG, 396 defined, 307
CookieCuller extension, 136 documentation, 25
cookies font modifications, 147
blocking, 110–111 resources, 309
defined, 109, 134 rules, 308–309
deleting, 110, 136 siteledsOverlay.css, 329
disabling, 170 specification, 309
Exceptions window, 110–111 standards, 25
expiration date, 135 theme creation, 389
privacy settings, 109, 134–135 tutorials, 389
removing, 110, 136 XUL documents, 307–308
Stored Cookies window, 110, 136 CSS Hacks and Filters: Making Cascading Stylesheets Work,
View Cookies extension, 55, 288–289 Joseph W. Lowery, 124
viewing, 110 current date/time, 54, 170–171
cookies.txt file current profile, 272
backup, 15, 275 currentTarget property, 359
contents, 270 custom installer
copying plugins, 218–220 creating, 256–259
Corel Paint Shop Pro, 323 dialogs, 258
cpuinfo program, 97 full installer, 258
CPU-Z tool, 96 stub installer, 258–259
Create Profile wizard (Profile Manager), 268–269 Customize Toolbar window, 158–159
creating customizing
custom installer, 256–259 Firefox
dialogs, 361–362 context menus, 366–368
dynamic overlays, 327–329 keyboard shortcuts, 368–369
favicons, 77 menus, 366–368
Master Password, 104 toolbar buttons, 369–371
preferences, 365 toolbars, 369–370
profiles, 5, 249–250, 268–269 menus
themes colors, 147
contents.rdf file, 385–386 Compact Menu extension, 147–149
CSS (Cascading Style Sheets), 389 CuteMenus extension, 153–155
default theme file, 383 font style, 147
DOM Inspector, 387–389 font weight, 147
extension buttons, 396–399 fonts, 146–147
file types, 381 Hacked CuteMenus extension, 154
graphics, 389–396 icons, 150–153
GUID generator, 386–387 Menu Editor extension, 149–150
install.rdf file, 384–385 spacing, 145–146
packaging the files, 399
Index C–D ■ 409
toolbars MIME types, 210–212
adding items, 143 plugins, 217–218
Customize Toolbar window, 158–159 DHTML (dynamic HTML), 134
flexible space, 158–159 dialog element, 361–362
moving items, 159 dialogs
reducing space around icons, 65–67 creating, 361–362
removing items, 143, 158–159 custom installer, 258
CuteMenus extension, 53, 153–155 disabling, 248
modal dialogs, 361
D opening, 362
data types of preferences, 364 windows, 361
date/time, 54, 170–171 DICT network protocol, 229
-dd parameter (installer), 244–245 DICT Search extension, 229
debug messages, 342–343 DictionarySearch extension, 227–229
debugging extensions directories
logging, 342 Backup directory, 13
preferences settings, 341–342 chrome directory, 334
debugging JavaScript extensions, 46–47
Configuration Mania extension, 283 profiles, 271
JavaScript Console extension, 8–9, 293 user path, 10–13
JavaScript Debugger extension, 293 directory structure
debugging tools extensions, 334
JavaScript Console, 342 themes, 383–384
standard console, 342 Disable Targets For Downloads extension, 53, 206–208
Venkman extension, 343 disabling
defaults automatic extension installation, 114
download location, 198 cookies, 170
Google search, 223 dialog windows, 248
home page, 179 extensions, 320
theme file, 383 JavaScript, 114–115, 170
defaults.ini file, 270 plugin support for specific file extensions, 220
Delete Icons extension, 79 smooth scrolling, 88
deleting Windows shell: protocol, 115
cookies, 110, 136 disk cache
favicons, 77–78 changing disk space amount, 92–93
icons, 79 changing location of, 91–92
individual items from browsing history, 108 statistics, 92
menus, 143–145 viewing, 92
profiles, 269–270 DNS (Domain Name Server) resolution information, 86
themes, 70 document events, 357
toolbar items, 143 Document Inspector
deploying Document - DOM Nodes panel, 6
extensions, 343 extensions
plugins, 251 programming, 346–349
themes, 401 troubleshooting, 343
description element, 353 installing, 3–5
description of an extension, 339 theme creation, 387–388
desktop icons (Windows), 253 themes, 389
desktop-icon.nsi source code, 254–256 troubleshooting, 5
detecting XUL, 6–7, 292
external download managers, 214–215 Document Object Model (DOM), 309–314
MIME type spoofing, 213 documentation for CSS, 25