临时解决 Proxy Switchy 不能自动切换的bug

翟二喜

chrome 中的上网翻墙必备工具 proxy switchy 在我的两台电脑上先后不能自动切换了,很是奇怪。

发现竟然是在设制 pac 文件时,文件名多了一个c。

貌似这两天电脑都是在装了 win7 sp1 之后发生的这个问题,问题出在 npSwitchy.dll 的某函数返回结果中。

于是,在js找到了适当的位置,手动解决一下这个bug吧:

1. 在google的扩展目录中找到proxy switchy的目录,AppData\Local\Google\Chrome\User Data\Default\Extensions\caehdcpeofiiigpdhbabniblemipncjj

2. 进入其子目录 1.6.3_0\assets\scripts

3. 编辑文件 ruleManager.js

4. 找到 RuleManager.getAutoPacScriptPath 函数,

加入下面代码中有注释的那行。

RuleManager.getAutoPacScriptPath = function getAutoPacScriptPath(withSalt) {
	if (RuleManager.autoPacScriptPath == undefined) {
		var plugin = chrome.extension.getBackgroundPage().plugin;
		try {
			RuleManager.autoPacScriptPath = plugin.autoPacScriptPath;
			// 下面这行是新加的
			// RuleManager.autoPacScriptPath = RuleManager.autoPacScriptPath.replace(/\.pacc$/gi, ".pac");
			RuleManager.autoPacScriptPath = RuleManager.autoPacScriptPath.replace(/\.pac.$/gi, ".pac");
		} catch(ex) {
			Logger.log("Plugin Error @RuleManager.getAutoPacScriptPath() > " + ex.toString(), Logger.Types.error);
			return undefined;
		}
	}

	return RuleManager.autoPacScriptPath + (withSalt ? "?" + new Date().getTime() : "");
}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:5   其中:访客  0   博主  0

  1. Find 0

    正则表达式是不是出错了?我试了多次都不行。后来改了
    // 下面这行是新加的
    RuleManager.autoPacScriptPath = RuleManager.autoPacScriptPath.replace(/\.pacc$/gi, “.pac”);
    改为:
    RuleManager.autoPacScriptPath = RuleManager.autoPacScriptPath.replace(/\.pacc/g, “.pac”);
    能用。不知道是否正确,对正则表达式不熟悉。

    • 没脾气2x 1

      @Find 我现在用的是
      RuleManager.autoPacScriptPath = RuleManager.autoPacScriptPath.replace(/\.pac.$/gi, “.pac”);

      i 可以去掉,因为这里没有大小写问题。
      $ 我现在还留着,因为我这里出现的全是 .pacc 或 .pace 后面没有其它东西。
      因为不知为何有此错误,所以改动还得随着变化而变化。

  2. Millyn 0

    是添加吗?添加之后 在设置页面无法保存设置怎么回事?

  3. 没脾气2x 1

    @Millyn

    程序行写全了吗?现在blog的模版让上面这行没显示全。

  4. fengerzh 0

    我这里的问题是它后面会跟上莫名其妙的乱码,用正则会出错,所以我用了下面的语句:
    RuleManager.autoPacScriptPath = RuleManager.autoPacScriptPath.substr(0, RuleManager.autoPacScriptPath.indexOf(“.pac”) + 4);