Page 1 of 1 1
Topic Options
#202602 - 2011-07-07 11:19 PM Help with XML
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
With Firefox upgrading their browser so often it is "breaking" the plugins. Luckily, the fix is easy. Find the install.rdf file for the individual plugin in the extensions folder (%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\somefolder.default\extensions\specificplugin), and update the em:maxVersion attribute to the current version, or if you are feeling real lucky, just change the value to *. The RDF file is nothing but an XML file.

Here is an example of a install.rdf file

 Code:
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">

    <Description about="urn:mozilla:install-manifest">
        <em:id>{3d7eb24f-2740-49df-8937-200b1cc08f8a}</em:id>
        <em:type>2</em:type>
        <em:unpack>true</em:unpack>
        <em:name>Flashblock</em:name>
        <em:version>1.5.14.2</em:version>
        <em:description>Replaces Flash objects with a button you can click to view them.</em:description>
        <em:creator>The Flashblock Team</em:creator>
        <em:contributor>Ted Drake</em:contributor>
        <em:contributor>Ted Mielczarek</em:contributor>
        <em:contributor>Przemyslaw Bialik</em:contributor>
        <em:contributor>Lorenzo Colitti</em:contributor>
        <em:contributor>Philip Chee</em:contributor>
        <em:contributor>Special thanks to:</em:contributor>
        <em:contributor> - Jesse Ruderman (initial idea)</em:contributor>
        <em:contributor> - Neil Rashbrook (whitelist wizardry)</em:contributor>
        <em:homepageURL>http://flashblock.mozdev.org/</em:homepageURL>
        <em:iconURL>chrome://flashblock/content/flashblock-32.png</em:iconURL>
        <em:optionsURL>chrome://flashblock/content/options.xul</em:optionsURL>

        <!-- Firefox -->
        <em:targetApplication>
            <Description>
                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
                <em:minVersion>2.0</em:minVersion>
                <em:maxVersion>6.0</em:maxVersion>
            </Description>
        </em:targetApplication>

        <!-- Flock  -->
        <em:targetApplication>
            <Description>
                <em:id>{a463f10c-3994-11da-9945-000d60ca027b}</em:id>
                <em:minVersion>1.0</em:minVersion>
                <em:maxVersion>2.9.*</em:maxVersion>
            </Description>
        </em:targetApplication>

        <!-- Netscape Navigator -->
        <em:targetApplication>
            <Description>
                <em:id>{3db10fab-e461-4c80-8b97-957ad5f8ea47}</em:id>
                <em:minVersion>9.0b1</em:minVersion>
                <em:maxVersion>9.0.*</em:maxVersion>
            </Description>
        </em:targetApplication>


The important part of this file is here:
 Code:
        <!-- Firefox -->
        <em:targetApplication>
            <Description>
                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
                <em:minVersion>2.0</em:minVersion>
                <em:maxVersion>6.0</em:maxVersion>
            </Description>
        </em:targetApplication>


You need to make sure you are in the right node of the xml file before making changes because mulitple products can be defined. The em:id of {ec8030f7-c20a-464f-9b0e-13a3a9e97384} is the Firefox identifier. The em:maxversion needs to be checked/updated.

I tried using some of the UDFs posted here: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=192905#Post192905
and also tried using combinations of getElementsByTagName, but feel like I am in over my head.

Can someone give me some direction?

Top
#202603 - 2011-07-08 01:17 AM Re: Help with XML [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Why dont you just go oldschool with the readline/writeline? Not as elegant as using the actual XML but would it still work?

 Code:
$file1 = "%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\nc5dyw3r.default\extensions\support@@plugin.com\install.rdf"
$file2 = "%userprofile%\AppData\Roaming\Mozilla\Firefox\Profiles\nc5dyw3r.default\extensions\support@@plugin.com\install2.rdf"
$newffver = "*"

$fh1 = FreeFileHandle()
If Open($fh1,$file1) = 0
   $fh2 = FreeFileHandle()
   If Open($fh2,$file2,5) = 0
      $line = ReadLine($fh1)
      While @Error=0
         If Instr($line,"ec8030f7-c20a-464f-9b0e-13a3a9e97384")
            $ff=1
         Endif
         If Instr($line,"em:maxVersion") AND $ff
            $nul = WriteLine($fh2,"       <em:maxVersion>"+$newffver+"</em:maxVersion>"+@CRLF)
            $ff=0
         Else
            $nul = WriteLine($fh2,$line+@CRLF)
         Endif
         $line = ReadLine($fh1)
      Loop
      $nul = Close($fh2)
      $nul = Close($fh1)
      Move $file1 $file1+".bak"
      Move $file2 $file1
   Else
      $nul = Close($fh1)
   Endif
Endif

Top
#202609 - 2011-07-08 03:50 PM Re: Help with XML [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Thanks Shane. This would work for properly formated xml files. Unfortunately, I have at least one example where the file is one long line \:\( . Sorry I didn't mention it before.

It's so funny to me how I remember XML was the future... and how little it seems to be used, at least in a scripting environment.

Any other ideas?

Top
#202612 - 2011-07-08 11:17 PM Re: Help with XML [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Well...making a bit of progress. Still trying to figure out how to differentiate one maxVersion from the others though since they are all lumped under the same em:...

I did get this to change the maxVersion value though!


 Code:
$xmlfile=@ScriptDir+"\input.xml"
$outfile=@ScriptDir+"\output.xml"

$oparser=createobject("msxml2.domdocument")
$oparser.async=0
$oparser.validateOnParse=0
$oparser.resolveExternals=0
$nul = $oparser.load($xmlfile)

If @Error
   ? "Error: "+@SError
   get $
   exit 1
Endif

$oparser.setproperty("SelectionLanguage","XPath")
$oparser.setproperty("SelectionNamespaces","xmlns:nem='http://www.mozilla.org/2004/em-rdf#'")
$onodelist=$oparser.selectSingleNode("//nem:maxVersion")
$onodelist.Text="*"

$nul = $oparser.save($outfile)

$onodelist=0
$oparser=0

Top
#202613 - 2011-07-08 11:47 PM Re: Help with XML [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
I've beaten my head on this one... finally making some progress too... I'll post it here in a minute.


Top
#202614 - 2011-07-08 11:54 PM Re: Help with XML [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Man what a pain. I had this all but working. The em:maxVersion kept coming up with the wrong value, and I couldn't figure out why until I actually counted how many were in the xml file. There is one more em:id than there are em:maxVersion's. Once I got that straight, I think I finally got it. Here is where I am now... still working on it, but progress \:\)

 Code:
break on
$RC=setoption("WrapAtEOL","ON")


$FireFoxVersion="5.0"
$objXMLDoc = CreateObject("Microsoft.XMLDOM")
$objXMLDoc.async = False
$RC=$objXMLDoc.load(@scriptdir + "\install (2).rdf")

$x=$objXMLDoc.documentElement.selectNodes("Description/em:targetApplication/Description")
for $i=0 to $x.length
  if $Objxmldoc.getelementsbytagname("em:id").item($i).text="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
    ? "Firefox"
    ? $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text
    ? $Objxmldoc.getelementsbytagname("em:id").item($i).text
    if $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text<>$FirefoxVersion
      ? "saving"
      $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text=$FirefoxVersion
      $objxmldoc.save(@scriptdir + "\changed.xml")
    endif
  endif
next



Edited by Allen (2011-07-09 12:03 AM)

Top
#202615 - 2011-07-09 12:10 AM Re: Help with XML [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Oh sweet... I just found a nice side effect. I tested this on the file that was poorly formatted and it worked, AND the new file is now properly formatted.
Top
#202616 - 2011-07-09 12:17 AM Re: Help with XML [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Yeah I noticed that when testing too. Also you can set the $objXMLDoc.preservewhitespace=1 setting if you ever want to maintain the formatting.
Top
#202617 - 2011-07-09 12:22 AM Re: Help with XML [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Have you noticed there a like 10 different xml objects you can use? I was so confused and not sure which to use. Some examples used one way, some used others. The best docs I found were for XMLDOM though...

http://www.devguru.com/Technologies/xmldom/quickref/xmldom_index.html

Top
#202618 - 2011-07-09 12:33 AM Re: Help with XML [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Yeah I saw a couple. I just wrote mine off of a sample vbscript I found.
Top
#202623 - 2011-07-09 10:26 PM Re: Help with XML [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Code
$FireFoxVersion=Readvalue(HKLMSoftware32 + "\Mozilla\Mozilla Firefox","")
 
for each $folder in dirplus("%appdata%\Mozilla\Firefox\Profiles\","/ad") if right($folder,8)=".default" for each $plugfolder in dirplus($folder + "\extensions","/ad") ? $plugfolder.name " - " + iif(FirefoxUpdatePlugin($plugfolder,$firefoxversion)=0,"Updated","Unchanged") next endif next

Functions
function FirefoxUpdatePlugin($path,$version)
  dim $objXMLDoc, $RC, $FirefoxEMID, $AppNodes, $i
  $FirefoxUpdatePlugin=1
  $objXMLDoc = CreateObject("Microsoft.XMLDOM")
  $objXMLDoc.async = False
  if exist($path + "\install.rdf")
    $RC=$objXMLDoc.load($path + "\install.rdf")
    $FirefoxEMID="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
    $AppNodes=$objXMLDoc.documentElement.selectNodes("Description/em:targetApplication/Description")
    for $i=0 to $AppNodes.length
      if $Objxmldoc.getelementsbytagname("em:id").item($i).text=$FirefoxEMID
        if $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text<>$version
          $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text=$version
          $objxmldoc.save($path + "\temp.rdf")
          if comparefiletimes($path + "\temp.rdf",$path + "\install.rdf")
            move $path + "\install.rdf" $path + "\install.rdf.bak"
            move $path + "\temp.rdf" $path + "\install.rdf"
            $FireFoxUpdatePlugin=0
          endif
        endif
      endif
    next
  else
    exit 2
  endif
endfunction
 
function HKLMSoftware32 $HKLMSoftware32="HKLM\Software" + iif(@onwow64,"\WOW6432Node","") endfunction
Function DirPlus($path,optional $Options, optional $f, optional $sfflag) If not vartype($f) DIM $f EndIf If not vartype($sfflag) DIM $sfflag EndIf
DIM $file, $i, $temp, $item, $ex1, $mask,$mask1,$maskArray,$maskarray1, $ex2, $code, $CodeWeight, $targetWeight, $weight, $masktrue DIM $tarray[0]
$ex1 = SetOption(Explicit,on) $ex2 = SetOption(NoVarsInStrings,on) $codeWeight = 0
If not Exist($path) Exit(2) EndIf If not vartype($f) $f = CreateObject("Scripting.FileSystemObject").getfolder($path) EndIf If @ERROR $temp = SetOption(Explicit,$ex1) $temp = SetOption(NoVarsInStrings,$ex2) Exit(@ERROR) EndIf
For Each $temp In Split($options,"/") $temp=Trim($temp) Select Case left($temp,1) = "s" If not vartype($sfflag) If Val(right($temp,-1)) = 0 $sfflag = -1 Else $sfflag = Val(right($temp,-1)) EndIf EndIf Case Left($temp,1) = "a" Select Case Right($temp,-1)="d" $codeWeight = $codeWeight + 1 $temp = "if $file.type = 'File Folder' " Case Right($temp,-1)="-d" $codeWeight = $codeWeight + 1 $temp = "if $file.type <> 'File Folder' " Case Right($temp,-1)="s" $codeWeight = $codeWeight + 1 $temp = "if $file.attributes & 4 " Case Right($temp,-1)="-s" $codeWeight = $codeWeight + 1 $temp = "if ($file.attributes & 4)=0 " Case Right($temp,-1)="h" $codeWeight = $codeWeight + 1 $temp = "if $file.attributes & 2 " Case Right($temp,-1)="-h" $codeWeight = $codeWeight + 1 $temp = "if ($file.attributes & 2)=0 " Case Right($temp,-1)="r" $codeWeight = $codeWeight + 1 $temp = "if $file.attributes & 1 " Case Right($temp,-1)="-r" $codeWeight = $codeWeight + 1 $temp = "if ($file.attributes & 1)=0 " Case Right($temp,-1)="a" $codeWeight = $codeWeight + 1 $temp = "if $file.attributes & 32 " Case Right($temp,-1)="-a" $codeWeight = $codeWeight + 1 $temp = "if ($file.attributes & 32)=0 " EndSelect $code = $temp + "$weight=$weight+1 endif" +@CRLF + $code
Case Left($temp,1) = "m" $maskarray = Split(Right($temp,-2),"|") $codeweight = $codeweight + 1 $code = "$masktrue=0 for Each $mask in $maskarray if instr($file.name,$mask) $masktrue=1 " + "EndIf Next If $masktrue $weight=$weight+1 endif" + @CRLF +$code Case Left($temp,1) = "f" $maskarray1 = Split(Right($temp,-2)," ") $codeweight = $codeweight + 1 $code = "$masktrue=0 for Each $mask1 in $maskarray1 if substr($file.name,Instrrev($file.name,'.')+1)" + "=$mask1 $masktrue=1 EndIf Next If $masktrue $weight=$weight+1 endif" + @CRLF +$code
EndSelect Next $code = "$weight = 0 $targetWeight = " + $codeweight + @CRLF + $code $code = $code + "if $weight = $targetweight Exit(1) endif"
For Each $file In $f.subfolders If Execute($code) $tarray[$i] = $file $i = $i + 1 ReDIM preserve $tarray[$i] EndIf If $sfflag $temp = dirplus($file,$options,$file,$sfflag-1) For Each $item In $temp $tarray[$i] = $item $i = $i + 1 ReDIM preserve $tarray[$i] Next EndIf Next For Each $file In $f.files If Execute($code) $tarray[$i] = $file $i = $i + 1
ReDIM preserve $tarray[$i] EndIf Next
If $i ReDIM preserve $tarray[$i-1] $i=0 Else $tarray = 0 EndIf
$dirplus = $tarray $temp = SetOption(Explicit,$ex1) $temp = SetOption(NoVarsInStrings,$ex2) Exit(@ERROR) EndFunction

Top
#202624 - 2011-07-09 11:38 PM Re: Help with XML [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Looks good Allen...Just one thing...

 Code:
        if $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text<>$FirefoxVersion
          $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text=$FirefoxVersion

Should maybe be...?
 Code:
        if $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text<>$Version
          $Objxmldoc.getelementsbytagname("em:maxVersion").item($i-1).text=$Version

Didn't see the $version parameter in the UDF called on anywehre.

Top
#202625 - 2011-07-09 11:40 PM Re: Help with XML [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Good catch. Thanks.

I'll fix that in the code above.

Top
#203154 - 2011-09-27 07:27 PM Re: Help with XML [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Well Hell!!! Firefox 7 breaks my updater already. I think I got to use it for version 5 and 6... and now even though I have updated the addons for ver 7, it says they are all unsupported.

I'll be looking for a way to do this again, if anyone has suggestions.

Top
#203155 - 2011-09-27 07:37 PM Re: Help with XML [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Some positive news... with the Firefox Addon Compatibility Reporter you can re-enable your addons.

Firefox Addon Compatibility Reporter
https://addons.mozilla.org/en-US/firefox/addon/add-on-compatibility-reporter/

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 394 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.072 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org