::-- hoxide [2006-12-13 08:27:39] """ 未完成 """

1. 想法

从网上下了很多Firefox的插件, 保存在本地. 对于我来说直接升级或者点击安装插件的问题是, 如果重装ff,插件都要再次从网上下载, 而我访问国外网站非常不方便. 将插件放在本地, 安装时也不容易, 我发现的可行的方法是把插件拖到打开的FF窗口, 这样它会显示安装界面, 这样非常不方便. 于是想到用GM做个插件.

2. 原理

对包含FF插件的目录应用GM, 编写js改写FF的对目录的网页呈现. 参考了Mozilla官方网站上关于安装插件的脚本.

3. 程序

#javascript 
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// ==UserScript==
// @name          Rewrite Firefox Add-ons
// @namespace     http://www.woodpecker.org.cn/
// @description   a script to rewrite Firefox addon files to let it can be install
// @include       file:///f:/down/software/mozilla/*
// ==/UserScript==

function main()
{
  var allA, thisA;
  allA = document.getElementsByTagName('a');
  for (var i = 0; i < allA.length; i++) {
    thisA = allA[i];
    if(thisA.text.match(/^.*\.xpi$/))
    {
      GM_log(thisA.text);
    }
    else if(thisA.text.match(/^.*\.jar$/))
    {
      GM_log('Change to Themes:'+thisA.text);
    }
    
  }
}

main();