Changeset 740

Show
Ignore:
Timestamp:
05/27/08 08:31:59 (6 months ago)
Author:
singpoly..@gmail.com
Message:

merge with trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/compiler

    • Property svn:ignore changed from
      build
      greasemonkey.xpi
      to
      build
      greasemonkey*.xpi
  • branches/compiler/build.sh

    r585 r740  
    11#!/bin/sh 
    2 GMMAX=0 
    3 GMMIN=8 
     2 
     3# Set up variables 
     4GMMAX=${1-0} 
     5GMMIN=${2-8} 
     6GMREL=${3-0} 
    47GMBUILD=`date +"%Y%m%d"` 
    5 GMREL=0 
    6  
    78GMNAME=greasemonkey 
    8  
    99GMVER="$GMMAX.$GMMIN.$GMBUILD.$GMREL" 
    1010GMXPI="$GMNAME-$GMVER.xpi" 
    1111 
    1212# Copy base structure to a temporary build directory and change to it 
     13echo "Creating working directory ..." 
    1314rm -rf build 
    1415mkdir build 
    15 cp chrome.manifest build/ 
    16 cp install.js build/ 
    17 cp install.rdf build/ 
    18 cp license.txt build/ 
    19 cp -r defaults build/ 
    20 cp -r components build/ 
    21 cp -r chrome build/ 
     16cp -r chrome.manifest install.rdf license.txt \ 
     17        defaults components chrome \ 
     18        build/ 
    2219cd build 
    2320 
    24 # Generate locales for chrome.manifest from babelzilla directories, which 
    25 # we assume have been placed in locale/. 
     21echo "Gathering all locales into chrome.manifest ..." 
    2622GMLOC=\"en-US\" 
    27 for entry in $(ls chrome/chromeFiles/locale/); do 
     23for entry in chrome/chromeFiles/locale/*; do 
    2824  if [ $entry != en-US ]; then 
    29     echo "locale  $GMNAME  "$entry"  chrome/chromeFiles/locale/"$entry"/" >> chrome.manifest 
     25    echo "locale  $GMNAME  $entry  chrome/chromeFiles/locale/$entry/" >> chrome.manifest 
    3026    GMLOC=$GMLOC,\ \"$entry\" 
    3127  fi 
    3228done 
    3329 
    34 replace () { 
    35   TMP=`mktemp -t Greasemonkey-build.sh` 
    36   SRC=`echo "$1" | sed 's/[\/\\\\]/\\\\&/g'` 
    37   DST=`echo "$2" | sed 's/[\/\\\\]/\\\\&/g'` 
    38   sed "s/$SRC/$DST/g" "$3" > "$TMP" 
    39   if cmp -s "$3" "$TMP" ; then 
    40     # No change! Treat as a failure to react to in caller. 
    41     rm "$TMP" 
    42     return 1 
    43   fi 
    44   cp "$TMP" "$3" 
    45   rm "$TMP" 
    46   return 0 
    47 
     30echo "Patching install.rdf version ..." 
     31sed "s!<em:version>.*</em:version>!<em:version>$GMVER</em:version>!" \ 
     32  install.rdf > install.rdf.tmp 
     33mv install.rdf.tmp install.rdf 
    4834 
    49 replace '<em:version>.*</em:version>' \ 
    50         '<em:version>'$GMVER'</em:version>' \ 
    51         install.rdf 
     35echo "Cleaning up unwanted files ..." 
     36find . -depth -name '.svn' -exec rm -rf "{}" \; 
     37find . -depth -name '*~' -exec rm -rf "{}" \; 
     38find . -depth -name '#*' -exec rm -rf "{}" \; 
    5239 
    53 replace 'const APP_VERSION =.*' \ 
    54         'const APP_VERSION = "'$GMVER'";' \ 
    55         install.js 
     40echo "Creating $GMNAME.jar ..." 
     41cd chrome 
     42zip -qr0X "$GMNAME.jar" chromeFiles icons 
     43rm -rf chromeFiles icons 
     44cd .. 
    5645 
    57 # sets up available locales for seamonkey 
    58 replace 'const APP_LOCALES =.*;' \ 
    59         'const APP_LOCALES = [ '$GMLOC' ];' \ 
    60         install.js 
     46echo "Patching chrome.manifest with jar ..." 
     47sed -e "/^content/s#\(.*\) chrome/\(.*\)#\1 jar:chrome/$GMNAME.jar!/\2#" \ 
     48    -e  "/^locale/s#\(.*\) chrome/\(.*\)#\1 jar:chrome/$GMNAME.jar!/\2#" \ 
     49    -e    "/^skin/s#\(.*\) chrome/\(.*\)#\1 jar:chrome/$GMNAME.jar!/\2#" \ 
     50    chrome.manifest > chrome.manifest.jar 
     51mv chrome.manifest.jar chrome.manifest 
    6152 
    62 find . -name '.svn' -prune -or -name '.DS_Store' -or -name '*~' -or -name '#*' \ 
    63   -or -print | zip -9X -@ "$GMXPI" 
     53echo "Creating $GMXPI ..." 
     54zip -qr9X "../$GMXPI" * 
    6455 
    65 mv "$GMXPI" ../ 
    66  
    67 echo "Created $GMXPI" 
    68 exit 0 
     56echo "Cleaning up temporary files ..." 
     57cd .. 
     58rm -rf build 
  • branches/compiler/chrome/chromeFiles/content/accelimation.js

    r548 r740  
    3535  this.id = Accelimation.instances.length; 
    3636  this.onend = null; 
    37 }; 
     37} 
    3838 
    3939//===================================================================== 
  • branches/compiler/chrome/chromeFiles/content/browser.js

    r623 r740  
    2828  this.menuCommanders = []; 
    2929  this.currentMenuCommander = null; 
    30  
    31   GM_updateVersion(); 
    3230 
    3331  GM_listen(window, "load", GM_hitch(this, "chromeLoad")); 
     
    173171      "chrome://greasemonkey/content/icon_small.png", 
    174172      greeting, 
    175       this.bundle.getString('greeting.btn'), 
     173      this.bundle.getString("greeting.btn"), 
    176174      null /* default doc shell */, 
    177175      "install-userscript", 
     
    179177      "top", 
    180178      true /* show close button */, 
    181       "I" /* access key */); 
     179      this.bundle.getString("greeting.btnAccess") /* access key */); 
    182180  } else { 
    183181    // Firefox 2.0+ 
     
    199197      notificationBox.PRIORITY_WARNING_MEDIUM, 
    200198      [{ 
    201         label: this.bundle.getString('greeting.btn'), 
    202         accessKey: "I"
     199        label: this.bundle.getString("greeting.btn"), 
     200        accessKey: this.bundle.getString("greeting.btnAccess")
    203201        popup: null, 
    204202        callback: GM_hitch(this, "installCurrentScript") 
     
    233231  this.scriptDownloader_ = scriptDownloader; 
    234232 
    235   var ioSvc = Components.classes["@mozilla.org/network/io-service;1"] 
    236                         .getService(Components.interfaces.nsIIOService); 
    237   var uri = ioSvc.newFileURI(scriptDownloader.script.file); 
    238  
    239   var tab = this.tabBrowser.addTab(uri.spec); 
     233  var tab = this.tabBrowser.addTab(scriptDownloader.script.previewURL); 
    240234  var browser = this.tabBrowser.getBrowserForTab(tab); 
    241235 
     
    265259 
    266260GM_BrowserUI.installScript = function(script){ 
    267   var config = new Config(); 
    268   config.load(); 
    269   config.install(script); 
     261  GM_getConfig().install(script); 
    270262  this.showHorrayMessage(script.name); 
    271263}; 
     
    426418  // set the enabled/disabled state 
    427419  GM_BrowserUI.generalMenuEnabledItem.setAttribute("checked", GM_getEnabled()); 
    428 }; 
     420} 
    429421 
    430422function GM_showPopup(aEvent) { 
    431   var config = new Config(); 
    432   config.load(); 
     423  function urlsOfAllFrames(contentWindow) { 
     424    function collect(contentWindow) { 
     425      urls = urls.concat(urlsOfAllFrames(contentWindow)); 
     426    } 
     427    var urls = [contentWindow.location.href]; 
     428    Array.prototype.slice.call(contentWindow.frames).forEach(collect); 
     429    return urls; 
     430  } 
     431 
     432  function uniq(a) { 
     433    var seen = {}, list = [], item; 
     434    for (var i = 0; i < a.length; i++) { 
     435      item = a[i]; 
     436      if (!seen.hasOwnProperty(item)) 
     437        seen[item] = list.push(item); 
     438    } 
     439    return list; 
     440  } 
     441 
     442  function scriptsMatching(urls) { 
     443 
     444    function testMatchURLs(script) { 
     445 
     446      function testMatchURL(url) { 
     447        return script.matchesURL(url); 
     448      } 
     449 
     450      return urls.some(testMatchURL); 
     451    } 
     452 
     453    return GM_getConfig().getMatchingScripts(testMatchURLs); 
     454  } 
     455 
     456  function appendScriptToPopup(script) { 
     457    var mi = document.createElement("menuitem"); 
     458    mi.setAttribute("label", script.name); 
     459    mi.script = script; 
     460    mi.setAttribute("type", "checkbox"); 
     461    mi.setAttribute("checked", script.enabled.toString()); 
     462    popup.insertBefore(mi, tail); 
     463  } 
     464 
    433465  var popup = aEvent.target; 
    434   var url = getBrowser().contentWindow.document.location.href
     466  var tail = document.getElementById("gm-status-no-scripts-sep")
    435467 
    436468  // set the enabled/disabled state 
     
    439471  // remove all the scripts from the list 
    440472  for (var i = popup.childNodes.length - 1; i >= 0; i--) { 
    441     if (popup.childNodes[i].hasAttribute("value")) { 
     473    if (popup.childNodes[i].script) { 
    442474      popup.removeChild(popup.childNodes[i]); 
    443475    } 
    444476  } 
    445477 
    446   var foundInjectedScript = false; 
     478  var urls = uniq( urlsOfAllFrames( getBrowser().contentWindow )); 
     479  var runsOnTop = scriptsMatching( [urls.shift()] ); // first url = top window 
     480  var runsFramed = scriptsMatching( urls ); // remainder are all its subframes 
     481 
     482  // drop all runsFramed scripts already present in runsOnTop 
     483  for (var i = 0; i < runsOnTop.length; i++) { 
     484    var j = 0, item = runsOnTop[i]; 
     485    while (j < runsFramed.length) { 
     486      if (item === runsFramed[j]) { 
     487        runsFramed.splice(j, 1); 
     488      } else { 
     489        j++; 
     490      } 
     491    } 
     492  } 
    447493 
    448494  // build the new list of scripts 
    449   for (var i = 0, script = null; script = config.scripts[i]; i++) { 
    450     incloop: for (var j = 0; j < script.includes.length; j++) { 
    451       var pattern = convert2RegExp(script.includes[j]); 
    452       if (pattern.test(url)) { 
    453         for (var k = 0; k < script.excludes.length; k++) { 
    454           pattern = convert2RegExp(script.excludes[k]); 
    455           if (pattern.test(url)) { 
    456             break incloop; 
    457           } 
    458         } 
    459  
    460         foundInjectedScript = true; 
    461  
    462         var mi = document.createElement('menuitem'); 
    463         mi.setAttribute('label', script.name); 
    464         mi.setAttribute('value', i); 
    465         mi.setAttribute('type', 'checkbox'); 
    466         mi.setAttribute('checked', script.enabled.toString()); 
    467  
    468         popup.insertBefore(mi, document.getElementById("gm-status-no-scripts-sep")); 
    469  
    470         break incloop; 
    471       } 
    472     } 
    473   } 
    474  
     495  if (runsFramed.length) { 
     496    runsFramed.forEach(appendScriptToPopup); 
     497    var separator = document.createElement("menuseparator"); 
     498    separator.setAttribute("value", "hack"); // to get removed in the loop above 
     499    popup.insertBefore(separator, tail); 
     500  } 
     501  runsOnTop.forEach(appendScriptToPopup); 
     502 
     503  var foundInjectedScript = !!(runsFramed.length + runsOnTop.length); 
    475504  document.getElementById("gm-status-no-scripts").collapsed = foundInjectedScript; 
    476 }; 
     505} 
    477506 
    478507/** 
     
    482511function GM_popupClicked(aEvent) { 
    483512  if (aEvent.button == 0 || aEvent.button == 2) { 
    484     var config = new Config(); 
    485     config.load(); 
    486     var scriptNum=aEvent.target.value; 
    487     if (!config.scripts[scriptNum]) return; 
    488  
    489     if (aEvent.button == 0) { 
    490       // left-click: toggle enabled state 
    491       config.scripts[scriptNum].enabled=!config.scripts[scriptNum].enabled; 
    492       config.save(); 
    493     } else { 
    494       // right-click: open in editor 
    495       openInEditor(getScriptFile(config.scripts[scriptNum]), 
    496       document.getElementById("gm-browser-bundle") 
    497               .getString("editor.prompt")); 
    498     } 
     513    var script = aEvent.target.script; 
     514    if (!script) return; 
     515 
     516    if (aEvent.button == 0) // left-click: toggle enabled state 
     517      script.enabled =! script.enabled; 
     518    else // right-click: open in editor 
     519      openInEditor(script); 
    499520 
    500521    closeMenus(aEvent.target); 
    501522  } 
    502 }; 
     523} 
    503524 
    504525/** 
     
    510531  if (GM_getEnabled()) { 
    511532    this.statusImage.src = "chrome://greasemonkey/content/icon_small.png"; 
    512     this.statusImage.tooltipText = this.bundle.getString('tooltip.enabled'); 
     533    this.statusImage.tooltipText = this.bundle.getString("tooltip.enabled"); 
    513534  } else { 
    514535    this.statusImage.src = "chrome://greasemonkey/content/icon_small_disabled.png"; 
    515     this.statusImage.tooltipText = this.bundle.getString('tooltip.disabled'); 
     536    this.statusImage.tooltipText = this.bundle.getString("tooltip.disabled"); 
    516537  } 
    517538 
     
    524545    .getService(Components.interfaces.nsIWindowWatcher); 
    525546  windowWatcher.openWindow( 
    526     window, 'chrome://greasemonkey/content/newscript.xul', null, 
    527     'chrome,dependent,centerscreen,resizable,dialog', null 
     547    window, "chrome://greasemonkey/content/newscript.xul", null, 
     548    "chrome,dependent,centerscreen,resizable,dialog", null 
    528549  ); 
    529550}; 
     
    608629 
    609630// necessary for webProgressListener implementation 
    610 GM_BrowserUI.onProgressChange = function(webProgress,b,c,d,e,f){} 
    611 GM_BrowserUI.onStateChange = function(a,b,c,d){} 
    612 GM_BrowserUI.onStatusChange = function(a,b,c,d){} 
    613 GM_BrowserUI.onSecurityChange = function(a,b,c){} 
    614 GM_BrowserUI.onLinkIconAvailable = function(a){} 
     631GM_BrowserUI.onProgressChange = function(webProgress,b,c,d,e,f){}; 
     632GM_BrowserUI.onStateChange = function(a,b,c,d){}; 
     633GM_BrowserUI.onStatusChange = function(a,b,c,d){}; 
     634GM_BrowserUI.onSecurityChange = function(a,b,c){}; 
     635GM_BrowserUI.onLinkIconAvailable = function(a){}; 
    615636 
    616637GM_BrowserUI.showHorrayMessage = function(scriptName) { 
     
    632653 
    633654GM_BrowserUI.manageMenuItemClicked = function() { 
    634    window.openDialog("chrome://greasemonkey/content/manage.xul", "manager", 
    635     "resizable,centerscreen,modal"); 
     655   GM_openUserScriptManager(); 
    636656}; 
    637657 
  • branches/compiler/chrome/chromeFiles/content/browser.xul

    r590 r740  
    1111  <script type="application/x-javascript" src="chrome://greasemonkey/content/prefmanager.js" /> 
    1212  <script type="application/x-javascript" src="chrome://greasemonkey/content/convert2RegExp.js" /> 
    13   <script type="application/x-javascript" src="chrome://greasemonkey/content/versioning.js" /> 
    1413  <script type="application/x-javascript" src="chrome://greasemonkey/content/menucommander.js" /> 
    1514  <script type="application/x-javascript" src="chrome://greasemonkey/content/xmlhttprequester.js" /> 
     
    1716  <script type="application/x-javascript" src="chrome://greasemonkey/content/dochandler.js" /> 
    1817  <script type="application/x-javascript" src="chrome://greasemonkey/content/scriptdownloader.js" /> 
    19   <script type="application/x-javascript" src="chrome://greasemonkey/content/config.js" /> 
    2018  <script type="application/x-javascript" src="chrome://greasemonkey/content/browser.js" /> 
    2119  <script type="application/x-javascript" src="chrome://greasemonkey/content/accelimation.js" /> 
  • branches/compiler/chrome/chromeFiles/content/config.js