1
// This code is heavily inspired by Chris Pederick (useragentswitcher) install.js
2
// Contributors: Philip Chee, deathburger
4
// Philip Chee: Added installation of prefs, components, and locales.
5
// deathburger: Refactored to move all changable items to the top of the file.
7
// Editable Items Begin
8
var displayName = "Flashblock"; // The name displayed to the user (don't include the version)
10
var name = "flashblock"; // The leafname of the JAR file (without the .jar part)
12
// The following three sets of variables tell this installer script how your
13
// extension directory structure looks.
14
// If your jar file contains content/packagename use the second packageDir
15
// variable. Same rule applies for skinDir and localeDir. I set them up
16
// independent of each other just in case an extension layout is wacky.
17
//var packageDir = "/"
18
var packageDir = "/" + name + "/"
20
var skinDir = "/" + name + "/"
22
var localeDir = "/" + name + "/"
24
var locales = new Array( "en-US", "it-IT", "nl-NL", "de-DE",
25
"fr-FR", "pl-PL", "ko-KR", "pt-BR", "da-DK", "hu-HU", "cs-CZ", "es-ES",
26
"ru-RU", "ro-RO", "de-AT", "ja-JP", "zh-CN", "ar-YE", "ar-JO", "fi-FI",
27
"sv-SE", "sk-SK", "zh-TW", "tr-TR" );
28
var skins = new Array( "classic" ); // "modern"
29
var prefs = new Array( "flashblock.js" );
30
var components = new Array( );
31
var searchPlugins = new Array( );
33
// Mozilla Suite/Seamonkey stores all pref files in a single directory
34
// under the application directory. If the name of the preference file(s)
35
// is/are not unique enough, you may override other extension preferences.
36
// set this to true if you need to prevent this.
37
var disambiguatePrefs = false;
41
var jarName = name + ".jar";
42
var jarFolder = "content" + packageDir
45
var folder = getFolder("Profile", "chrome");
46
var prefFolder = getFolder(getFolder("Program", "defaults"), "pref");
47
var compFolder = getFolder("Components");
48
var searchFolder = getFolder("Plugins");
50
var existsInApplication = File.exists(getFolder(getFolder("chrome"), jarName));
51
var existsInProfile = File.exists(getFolder(folder, jarName));
53
var contentFlag = CONTENT | PROFILE_CHROME;
54
var localeFlag = LOCALE | PROFILE_CHROME;
55
var skinFlag = SKIN | PROFILE_CHROME;
57
var APP_PLATFORM = "";
58
var gPlatform = getPlatform();
60
// If the extension exists in the application folder or it doesn't exist
61
// in the profile folder and the user doesn't want it installed to the
63
if(existsInApplication ||
65
!confirm( "Do you want to install the " + displayName +
66
" extension into your profile folder?\n" +
67
"(Cancel will install into the application folder)")))
69
contentFlag = CONTENT | DELAYED_CHROME;
70
folder = getFolder("chrome");
71
localeFlag = LOCALE | DELAYED_CHROME;
72
skinFlag = SKIN | DELAYED_CHROME;
75
initInstall(displayName, name, version);
76
setPackageFolder(folder);
77
error = addFile(name, version, "chrome/" + jarName, folder, null);
79
// If adding the JAR file succeeded
82
folder = getFolder(folder, jarName);
84
registerChrome(contentFlag, folder, jarFolder);
85
for (var i = 0; i < locales.length; i++) {
86
registerChrome(localeFlag, folder, "locale/" + locales[i] + localeDir);
89
for (var i = 0; i < skins.length; i++) {
90
registerChrome(skinFlag, folder, "skin/" + skins[i] + skinDir);
93
for (var i = 0; i < prefs.length; i++) {
94
if (!disambiguatePrefs) {
95
addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
96
prefFolder, prefs[i], true);
98
addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
99
prefFolder, name + "-" + prefs[i], true);
103
for (var i = 0; i < components.length; i++) {
104
addFile(name + " Components", version, "components/" + components[i],
105
compFolder, components[i], true);
108
for (var i = 0; i < searchPlugins.length; i++) {
109
addFile(name + " searchPlugins", version, "searchplugins/" + searchPlugins[i],
110
searchFolder, searchPlugins[i], true);
113
error = performInstall();
115
// If the install failed
116
if(error != SUCCESS && error != REBOOT_NEEDED)
119
cancelInstall(error);
123
msg = displayName + " " + version + " has been succesfully installed.\n"
124
+ "Flash objects will now be replaced with a button that you can click on to view them.\n\n"
125
+ "Please restart your browser to enable " + displayName + ".";
132
cancelInstall(error);
135
// Displays the error message to the user
136
function displayError(error)
138
// If the error code was -215
139
if(error == READ_ONLY)
141
alert("The installation of " + displayName +
142
" failed.\nOne of the files being overwritten is read-only.");
144
// If the error code was -235
145
else if(error == INSUFFICIENT_DISK_SPACE)
147
alert("The installation of " + displayName +
148
" failed.\nThere is insufficient disk space.");
150
// If the error code was -239
151
else if(error == CHROME_REGISTRY_ERROR)
153
alert("The installation of " + displayName +
154
" failed.\nChrome registration failed.");
158
alert("The installation of " + displayName +
159
" failed.\nThe error code is: " + error);
163
function getPlatform() {
164
var platformStr, platformNode;
166
if ('platform' in Install) {
167
platformStr = new String(Install.platform);
168
APP_PLATFORM = platformStr;
169
// Mac OS X (aka Darwin) is a real unix system
170
if (!platformStr.search(/.*Darwin/))
171
platformNode = 'unix';
172
else if (!platformStr.search(/^Macintosh/))
173
platformNode = 'mac';
174
else if (!platformStr.search(/^Win/))
175
platformNode = 'win';
176
else if (!platformStr.search(/^OS\/2/))
177
platformNode = 'win';
178
else if (!platformStr.search(/unix|sun|linux/i))
179
platformNode = 'unix';
180
else if (getFolder("Unix Lib") != null)
181
platformNode = 'unix';
183
platformNode = 'unknown';
187
if (getFolder("Unix Lib") != null)
188
platformNode = 'unix';
189
else if (getFolder("Mac System")!= null)
190
platformNode = 'mac';
191
else if(getFolder("Win System")!= null)
192
platformNode = 'win';
194
platformNode = 'unknown';