aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.py2
-rw-r--r--chrome.manifest14
-rw-r--r--chrome/content/code/redirector.prototype.js15
-rw-r--r--chrome/locale/zh-CN/browserOverlay.xul.dtd9
-rw-r--r--chrome/locale/zh-CN/editRedirect.xul.dtd14
-rw-r--r--chrome/locale/zh-CN/redirector.properties33
-rw-r--r--chrome/locale/zh-CN/settings.xul.dtd65
-rw-r--r--components/redirector.component.js14
-rw-r--r--install.rdf5
9 files changed, 162 insertions, 9 deletions
diff --git a/build.py b/build.py
index bd561d1..0fd20df 100644
--- a/build.py
+++ b/build.py
@@ -6,7 +6,7 @@ for f in os.listdir('.'):
os.system(r'xpidl -m typelib -e ..\%s %s' % (f[:-3] + 'xpt',f))
os.chdir(r'..\..')
-xpi = zipfile.ZipFile('redirector-2.0.2.xpi','w')
+xpi = zipfile.ZipFile('redirector-2.5.xpi','w')
for (root, folders, files) in os.walk('.'):
if not '.svn' in root:
for f in files:
diff --git a/chrome.manifest b/chrome.manifest
index ec4e237..bc60f58 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -1,6 +1,18 @@
# $Id$
content redirector file:chrome/content/
locale redirector en-US file:chrome/locale/en-US/
+locale redirector zh-CN file:chrome/locale/zh-CN/
skin redirector classic/1.0 file:chrome/skin/
-overlay chrome://browser/content/browser.xul chrome://redirector/content/ui/browserOverlay.xul \ No newline at end of file
+overlay chrome://browser/content/browser.xul chrome://redirector/content/ui/browserOverlay.xul
+
+#FF4 registration
+interfaces components/rdIMatchResult.xpt
+interfaces components/rdIRedirect.xpt
+interfaces components/rdIRedirector.xpt
+
+component {b7a7a54f-0581-47ff-b086-d6920cb7a3f7} components/redirector.component.js
+contract @einaregilsson.com/redirector;1 {b7a7a54f-0581-47ff-b086-d6920cb7a3f7}
+category profile-after-change Redirector @einaregilsson.com/redirector;1
+category content-policy Redirector @einaregilsson.com/redirector;1
+category net-channel-event-sinks Redirector @einaregilsson.com/redirector;1 \ No newline at end of file
diff --git a/chrome/content/code/redirector.prototype.js b/chrome/content/code/redirector.prototype.js
index d7b4bc8..be920d8 100644
--- a/chrome/content/code/redirector.prototype.js
+++ b/chrome/content/code/redirector.prototype.js
@@ -143,6 +143,7 @@ Redirector.prototype = {
// nsIContentPolicy implementation
shouldLoad: function(contentType, contentLocation, requestOrigin, aContext, mimeTypeGuess, extra) {
+ rdump('nsIContentPolicy::ShouldLoad ' + contentLocation.spec);
try {
//This is also done in getRedirectUrl, but we want to exit as quickly as possible for performance
if (!this._prefs.enabled) {
@@ -181,10 +182,19 @@ Redirector.prototype = {
//end nsIContentPolicy
//nsIChannelEventSink implementation
+
+ //For FF4.0. Got this from a thread about adblock plus, https://adblockplus.org/forum/viewtopic.php?t=5895
+ asyncOnChannelRedirect: function(oldChannel, newChannel, flags, redirectCallback) {
+ this.onChannelRedirect(oldChannel, newChannel, flags);
+ redirectCallback.onRedirectVerifyCallback(0);
+ },
+
onChannelRedirect: function(oldChannel, newChannel, flags)
{
try {
let newLocation = newChannel.URI.spec;
+ rdump('nsIChannelEventSink::onChannelRedirect ' + newLocation);
+
if (!(newChannel.loadFlags & Ci.nsIChannel.LOAD_DOCUMENT_URI)) {
//We only redirect documents...
return;
@@ -242,12 +252,13 @@ Redirector.prototype = {
if (this._prefs) {
this._prefs.dispose();
}
+ this._cout.logStringMessage('REDIRECTOR CREATED');
this._prefs = new RedirectorPrefs();
//Check if we need to update existing redirects
var data = this._prefs.redirects;
var version = this._prefs.version;
this._loadStrings();
- var currentVersion = '2.0.2';
+ var currentVersion = '2.5';
//Here update checks are handled
if (version == 'undefined') { //Either a fresh install of Redirector, or first time install of v2.0
if (data) { //There is some data in redirects, we are upgrading from a previous version, need to upgrade data
@@ -264,7 +275,7 @@ Redirector.prototype = {
this._prefs.redirects = newArr.join(':::');
}
this._prefs.version = currentVersion;
- } else if (version == '2.0' || version == '2.0.1') {
+ } else if (version == '2.0' || version == '2.0.1' || version == '2.0.2') {
this._prefs.version = currentVersion;
}
//Update finished
diff --git a/chrome/locale/zh-CN/browserOverlay.xul.dtd b/chrome/locale/zh-CN/browserOverlay.xul.dtd
new file mode 100644
index 0000000..b0567f8
--- /dev/null
+++ b/chrome/locale/zh-CN/browserOverlay.xul.dtd
@@ -0,0 +1,9 @@
+<!-- $Id: browserOverlay.xul.dtd 249 2009-09-15 21:41:06Z einar@einaregilsson.com $ -->
+<!ENTITY RedirectorMenuItem.label "管理 URL 重定向">
+<!ENTITY RedirectorMenuItem.accesskey "R">
+<!ENTITY RedirectorContext.label "把 URL 添加到 Redirector 规则...">
+<!ENTITY RedirectorContext.accesskey "A">
+<!ENTITY RedirectorManageRedirects.label "管理规则">
+<!ENTITY RedirectorManageRedirects.accesskey "M">
+<!ENTITY RedirectorHelp.label "帮助">
+<!ENTITY RedirectorHelp.accesskey "H">
diff --git a/chrome/locale/zh-CN/editRedirect.xul.dtd b/chrome/locale/zh-CN/editRedirect.xul.dtd
new file mode 100644
index 0000000..f0ab422
--- /dev/null
+++ b/chrome/locale/zh-CN/editRedirect.xul.dtd
@@ -0,0 +1,14 @@
+<!-- $Id: editRedirect.xul.dtd 253 2009-10-07 11:24:44Z einar@einaregilsson.com $ -->
+<!ENTITY redirectWindow.title "Redirector">
+<!ENTITY txtExampleUrl.label "用于测试的 URL">
+<!ENTITY txtIncludePattern.label "使用规则">
+<!ENTITY txtExcludePattern.label "例外规则">
+<!ENTITY txtRedirectUrl.label "重定向到">
+<!ENTITY btnTestPattern.label "测试">
+<!ENTITY rdoWildcard.label "通配符(*)">
+<!ENTITY rdoWildcard.accessKey "W">
+<!ENTITY rdoRegex.label "正则表达式">
+<!ENTITY rdoPatternTypes.label "规则类型">
+<!ENTITY rdoRegex.accessKey "R">
+<!ENTITY chkUnescapeMatches.label "Unescape 匹配部分">
+
diff --git a/chrome/locale/zh-CN/redirector.properties b/chrome/locale/zh-CN/redirector.properties
new file mode 100644
index 0000000..866ec1a
--- /dev/null
+++ b/chrome/locale/zh-CN/redirector.properties
@@ -0,0 +1,33 @@
+# $Id: redirector.properties 288 2009-10-26 08:13:15Z einar@einaregilsson.com $
+initError=Failed to initialize Redirector.
+extensions.redirector@einaregilsson.com.description=根据您设置的规则自动跳转网页。
+extensionName=Redirector
+addCurrentUrl=Add current url to Redirector
+addLinkUrl=为链接创建 Redirector 规则
+recursiveError=A redirect with the pattern %S matches %S and is trying to redirect to it again. You should change this rule so it won't work recursively.
+enabledTooltip=Redirector is enabled
+disabledTooltip=Redirector is disabled
+testPatternSuccess=The pattern %S matches example URL %S, and would redirect you to url: %S
+testPatternFailure=The pattern %S does not match example URL %S
+testPatternExclude=Example URL %S matches the exclude pattern %S and so would not be redirected
+regexPatternError=The pattern '%S' is not a legal regular expression pattern. Details: %S
+xpathDeprecated=XPath patterns are no longer supported as of version 1.5.1, please remove those redirects.
+redirectorFiles=Redirector files (*.rdx)
+exportCaption=Export redirects...
+importCaption=Import redirects...
+deleteConfirmationText=Are you sure you want to permanently delete this redirect?
+deleteConfirmationTitle=Delete redirect?
+importedMessage=%S redirects were imported
+importedMessageSingular=%S redirect was imported
+existedMessage=%S redirects were identical to existing redirects and were therefore not imported.
+existedMessageSingular=%S redirect was identical to an existing redirect and was therefore not imported.
+allExistedMessage=All %S redirects in the file were identical to existing redirects, no redirects were imported.
+allExistedMessageSingular=The single redirect in the file was identical to an existing redirect and was therefore not imported.
+importedNone=There were no usable redirects in the given file, no redirects were imported.
+importResult=Import results
+invalidRedirectTitle=Redirector Add-on: Invalid Redirect detected
+invalidRedirectText=The pattern "%S" redirected the url %S to %S which also matches the pattern. This will cause an endless loop and so the redirect has been disabled to prevent this from happening. You should edit this redirect to fix it.
+warningExampleUrlDoesntMatchPatternTitle=Warning: Example url does not match redirect
+warningExampleUrlDoesntMatchPattern=The example url does not match the redirect specified. Are you sure you want to save this redirect?
+errorExampleUrlMatchesRecursiveTitle=Error: Recursive match detected
+errorExampleUrlMatchesRecursive=The example url %S matches the redirect and would redirect you to %S, which also matches the redirect. This is not allowed as it can cause an endless loop of requests. \ No newline at end of file
diff --git a/chrome/locale/zh-CN/settings.xul.dtd b/chrome/locale/zh-CN/settings.xul.dtd
new file mode 100644
index 0000000..0facb3a
--- /dev/null
+++ b/chrome/locale/zh-CN/settings.xul.dtd
@@ -0,0 +1,65 @@
+<!-- $Id: settings.xul.dtd 266 2009-10-14 11:13:03Z einar@einaregilsson.com $ -->
+<!ENTITY window.title "Redirector">
+
+<!-- ListItems with redirects -->
+<!ENTITY colIncludePattern.label "使用规则">
+<!ENTITY colExcludePattern.label "例外规则">
+<!ENTITY colRedirectTo.label "重定向到">
+<!ENTITY colEnabled.label "启用">
+
+<!-- Buttons -->
+<!ENTITY btnAdd.label "增加规则...">
+<!ENTITY btnAdd.accesskey "A">
+<!ENTITY btnAdd.tooltip "新建一条规则">
+
+<!ENTITY btnEdit.label "编辑规则...">
+<!ENTITY btnEdit.accesskey "E">
+<!ENTITY btnEdit.tooltip "编辑选定的规则">
+
+<!ENTITY btnDelete.label "删除规则">
+<!ENTITY btnDelete.accesskey "D">
+<!ENTITY btnDelete.tooltip "删除选定的规则">
+
+<!ENTITY btnUp.tooltip "把规则向上移动一条位置">
+
+<!ENTITY btnDown.tooltip "把规则向下移动一条位置">
+
+<!ENTITY btnImport.label "导入...">
+<!ENTITY btnImport.accesskey "I">
+<!ENTITY btnImport.tooltip "从文件导入规则">
+
+<!ENTITY btnExport.label "导出...">
+<!ENTITY btnExport.accesskey "E">
+<!ENTITY btnExport.tooltip "导出规则到文件">
+
+
+<!-- Tab headers -->
+<!ENTITY tabRedirects.label "重定向规则">
+<!ENTITY tabRedirects.accesskey "R">
+<!ENTITY tabPreferences.label "选项">
+<!ENTITY tabPreferences.accesskey "P">
+<!ENTITY tabImportExport.label "导入/导出">
+<!ENTITY tabImportExport.accesskey "m">
+<!ENTITY tabHelp.label "帮助">
+<!ENTITY tabHelp.accesskey "H">
+
+<!-- Preferences -->
+<!ENTITY grpGeneralPreferences.label "一般">
+<!ENTITY grpDebuggingPreferences.label "调试">
+
+<!ENTITY chkEnableRedirector.label "启用 Redirector">
+<!ENTITY chkEnableRedirector.accesskey "E">
+
+<!ENTITY chkShowStatusBarIcon.label "在状态栏显示图标">
+<!ENTITY chkShowStatusBarIcon.accesskey "s">
+
+<!ENTITY chkShowContextMenu.label "在右键菜单中显示">
+<!ENTITY chkShowContextMenu.accesskey "c">
+
+<!ENTITY chkEnableDebugOutput.label "启用调试输出">
+<!ENTITY chkEnableDebugOutput.accesskey "d">
+
+
+<!-- Import / Export -->
+<!ENTITY lblExport.label "将规则导出到文件">
+<!ENTITY lblImport.label "从文件导入规则">
diff --git a/components/redirector.component.js b/components/redirector.component.js
index ee2e584..751f548 100644
--- a/components/redirector.component.js
+++ b/components/redirector.component.js
@@ -6,6 +6,9 @@ Cr = Components.results;
Cc = Components.classes;
const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
+function rdump(msg) {
+ //dump('\nREDIRECTOR: ' + msg);
+}
var redirector = null;
function Redirector() {
this._init();
@@ -16,6 +19,7 @@ try {
loader.loadSubScript('chrome://redirector/content/code/redirect.js');
loader.loadSubScript('chrome://redirector/content/code/redirectorprefs.js');
} catch(e) {
+ rdump('ERROR: ' + e);
for (i in e) {
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage('REDIRECTOR: Loading Redirector implementation failed: ' + i + e[i]);
}
@@ -32,12 +36,16 @@ xpcomInfo._xpcom_factory = {
createInstance: function(outer, iid) {
if (outer) throw Cr.NS_ERROR_NO_AGGREGATION;
if (redirector == null) {
+ rdump('Creating new instance');
redirector = new Redirector();
+ } else {
+ rdump('Using existing instance');
}
return redirector.QueryInterface(iid);
}
};
-function NSGetModule(compMgr, fileSpec) {
- return XPCOMUtils.generateModule([Redirector]);
-}
+if (XPCOMUtils.generateNSGetFactory)
+ var NSGetFactory = XPCOMUtils.generateNSGetFactory([Redirector]);
+else
+ var NSGetModule = XPCOMUtils.generateNSGetModule([Redirector]); \ No newline at end of file
diff --git a/install.rdf b/install.rdf
index a95dc44..2e54ff7 100644
--- a/install.rdf
+++ b/install.rdf
@@ -5,8 +5,9 @@
<Description about="urn:mozilla:install-manifest">
<em:id>redirector@einaregilsson.com</em:id>
<em:name>Redirector</em:name>
- <em:version>2.0.2</em:version>
+ <em:version>2.5</em:version>
<em:creator>Einar Egilsson</em:creator>
+ <em:contributor>quaful Zhang (Simplified Chinese locale)</em:contributor>
<em:description>Automatically redirects to user-defined urls on certain pages</em:description>
<em:homepageURL>http://tech.einaregilsson.com/projects/redirector/</em:homepageURL>
<em:optionsURL>chrome://redirector/content/ui/settings.xul</em:optionsURL>
@@ -15,7 +16,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- firefox -->
<em:minVersion>3.5</em:minVersion>
- <em:maxVersion>3.6.*</em:maxVersion>
+ <em:maxVersion>4.0b6</em:maxVersion>
</Description>
</em:targetApplication>
</Description>