converts firefox extensions to kmeleon
download from kmext/development
mainly for experimental and testing purposes
auto extracts xpi files, copies jar file to km\chrome, modifies and renames manifest file.. if no manifest file exist inside xpi it generates a standard manifest with proper jar name. generates testing macro according to the chrome jar.
few xpi extensions do not include a compressed jar(especially those written with macos x in mind), converter will abort if no jar. after converting the extension, test it from tools menu>pending extension. if an extension works, then rename and edit the macro(testermacro.kmm); otherwise it will be overwritten with the next extension conversion.
extract KMextvert anywhere you like.. it can run directly(prompt for extension) or from context menu(parameter) of an xpi file.
on first run, km-extvert will prompt for k-meleon's folder path and will save it to an ini file
if you change k-meleon's path or copy the folder to another pc then you must delete extvert.ini to generate the new km path.
ofcourse this is only an easy test to check if an extension is capable of working in km or not.. extensions that rely on ff overlays and sidebars will not work.
source:
; AutoIt Version: 3.0
; Language: Gibberish
; Platform: Win9x/NT
; Author: yanni
; Script Function: experimental
#NoTrayIcon
#Include <String.au3>
#Include <File.au3>
#Include <Array.au3>
DirCreate(@TempDir & "\pend")
$7zpath =(@ScriptDir & "\7zxpi\7z.exe")
$pend = (@TempDir & "\pend\")
$pendparm1 = _StringInsert($pend, "-o", 0)
$pendparm2 = ($pendparm1 & " -y")
$pendparm3 = _StringInsert($pendparm2, " ", 0)
If FileExists(@ScriptDir & "\extvert.ini") Then
$kmpath = IniRead(@ScriptDir & "\extvert.ini", "kmeleon", "1", "default")
Else
$kmpath = FileSelectFolder("Select K-Meleon's Folder", "")
IniWrite(@ScriptDir & "\extvert.ini", "kmeleon", 1, $kmpath)
EndIf
;kmeleon folders
$macros = ($kmpath & "\macros")
$chrome = ($kmpath & "\chrome\")
$components = ($kmpath & "\components\")
$plugins = ($kmpath & "\plugins\")
$kmbinary = ($kmpath & "\k-meleon.exe")
if $CmdLine[0] = 0 Then
$extpath = FileOpenDialog("Select Extension", @WorkingDir & "", "Firefox Extensions (*.xpi)", 1 + 4 )
ElseIf $CmdLine[0] = 1 Then
$extpath = _PathFull($CmdLine[1])
EndIf
$extparm = ("x " & $extpath)
$overparm = ($extparm & $pendparm3)
shellexecute($7zpath, $overparm)
$manifest1 = _PathFull($pend & "chrome.manifest")
$manifestatic = (@ScriptDir & "\manipend\chrome.manifest")
$manikmpath = ($chrome & "\chrome.manifest")
$manifox = ("jar:chrome/")
$manikm = ("jar:")
$manicust = ("testpend")
;more crap
$manidefault = ("chrome.manifest")
$macropend = (@ScriptDir & "\macropend\testermacro.kmm")
$mstring = ("ubafuckera")
$pendingcomps =($pend & "components")
$pendingplugins =($pend & "plugins")
$deletable1 = ($kmpath & "\components\compreg.dat")
$deletable2 = ($kmpath & "\components\xpti.dat")
sleep(1400)
;fucking variables
$jarext1= ($pend)
$jarext2= ($pend & "\chrome\")
$jarfind1 = ($jarext1 & "\*.jar")
$jarfind2 = ($jarext1 & "\chrome\*.jar")
$jarfinder = FileFindFirstFile($jarfind1)
$jarlocate1 = FileFindNextFile($jarfinder)
$jarpath1 = _PathFull($pend & $jarlocate1)
$jarfinder2 = FileFindFirstFile($jarfind2)
$jarlocate2 = FileFindNextFile($jarfinder2)
$jarpath2= _PathFull($jarext2 & $jarlocate2)
$jarname1 = StringReplace($jarlocate1, ".jar", "")
$jarname2 = StringReplace($jarlocate2, ".jar", "")
Func editmanifest()
if FileExists($manifest1) Then
;MsgBox(4096, "Test", $manifest1, 10)
$readmanifest = FileRead($manifest1)
$readmanifest = StringReplace($readmanifest, $manifox, $manikm)
FileDelete($manifest1)
FileWrite($manifest1,$readmanifest)
FileClose($manifest1)
Else
;MsgBox(4096, "Test", "no fuck fuck", 10)
FileCopy($manifestatic, $pend, 8)
sleep(400)
EndIf
endFunc
Func setmanifest()
if $jarname1 = "" Then
;MsgBox(4096, "Fucker x", $jarname2)
sleep(40)
$extraneo2 = ($jarname2 & ".manifest")
$destkmchrome = ($chrome & $extraneo2)
;MsgBox(4096, "Fester", $destkmchrome)
FileMove($manifest1, $destkmchrome, 1)
sleep(2000)
$exreadmanifest = FileRead($destkmchrome)
$exreadmanifest = StringReplace($exreadmanifest, $manicust, $jarname2)
FileDelete($destkmchrome)
FileWrite($destkmchrome,$exreadmanifest)
else
;MsgBox(4096, "Fucker x2", $jarname1)
$extraneo1 = ($jarname1 & ".manifest")
$destkmchrome= ($chrome & $extraneo1)
;MsgBox(4096, "Fester", $destkmchrome)
FileMove($manifest1, $destkmchrome, 1)
sleep(2000)
$exreadmanifest = FileRead($destkmchrome)
$exreadmanifest = StringReplace($exreadmanifest, $manicust, $jarname1)
FileDelete($destkmchrome)
FileWrite($destkmchrome,$exreadmanifest)
endif
endFunc
Func setmacro()
FileCopy($macropend, $macros, 1)
$macrofinale = ($macros & "\testermacro.kmm")
if $jarname1 = "" Then
sleep(840)
$macroread = FileRead($macrofinale)
$macroread = StringReplace($macroread, $mstring, $jarname2)
FileDelete($macrofinale)
FileWrite($macrofinale,$macroread)
else
sleep(840)
$macroread = FileRead($macrofinale)
$macroread = StringReplace($macroread, $mstring, $jarname1)
FileDelete($macrofinale)
FileWrite($macrofinale,$macroread)
endif
endFunc
If $jarfinder > 0 Then
;MsgBox(4096, "File:", $jarpath1)
;MsgBox(4096, "File:", $jarname1)
ElseIf $jarfinder < 0 Then
;MsgBox(0, "Error", "No files/directories matched the search pattern")
;MsgBox(0, "Error", "searching secondary path")
$jarfinder2 = FileFindFirstFile($jarfind2)
$jarlocate2 = FileFindNextFile($jarfinder2)
If $jarfinder2 > 0 Then
$jarpath2= _PathFull($jarext2 & $jarlocate2)
;MsgBox(4096, "File:", $jarpath2)
;MsgBox(4096, "File:", $jarname2)
Else
;MsgBox(4096, "shit", "no fucking jar..fuck off")
MsgBox(4096, "Conversion Error! abandoning..", "Either the file selected isn't an xpi; or doesn't contain a chrome jar.")
Exit
EndIf
EndIf
Func copyjar()
If $jarfinder < 0 Then
;MsgBox(4096, "testjarshit", $jarpath2)
FileCopy($jarpath2, $chrome, 1)
elseIf $jarfinder2 < 0 Then
;MsgBox(4096, "testjarfuck", $jarpath1)
FileCopy($jarpath1, $chrome, 1)
EndIf
endFunc
func copyrest()
DirCopy($pendingcomps, $components, 1)
sleep(200)
DirCopy($pendingplugins, $plugins, 1)
endFunc
Func setkm()
FileDelete($deletable1)
sleep(40)
FileDelete($deletable2)
endFunc
Func firekm()
While Process]Exists("k-meleon.exe")
WinClose("[CLASS:KMeleon Browser Window]", "");
sleep(400);
If WinActive("K-Meleon") Then
Send("{Enter}")
EndIf
Wend
sleep(400)
Run($kmbinary)
endFunc
Func Cleanup()
DirRemove($pend, 1)
endFunc
ProgressOn("K-Meleon xpi extension converter", "initalising..", "0 percent", -1, -1, 16)
sleep(10)
ProgressSet(5, "6 percent", "generating chrome manifest")
editmanifest()
ProgressSet(10, "10 percent", "generating chrome manifest")
sleep(400)
ProgressSet(15, "15 percent", "copying manifest file")
setmanifest()
ProgressSet(20, "20 percent", "copying manifest file")
sleep(1000)
ProgressSet(25, "25 percent", "manifest set successfully")
sleep(40)
ProgressSet(30, "30 percent", "generating k-meleon macro ")
setmacro()
ProgressSet(35, "35 percent", "k-meleon macro completed")
sleep(800)
ProgressSet(40, "40 percent", "copying the jar file")
copyjar()
sleep(100)
ProgressSet(60, "60 percent", "finished copying the jar file")
sleep(100)
ProgressSet(65, "65 percent", "copying additonal files")
copyrest()
sleep(220)
ProgressSet(70, "70 percent", "setting-up K-Meleon")
setkm()
ProgressSet(80, "80 percent", "clearing temp files")
sleep(1000)
ProgressSet(82, "82 percent", "clearing temp files")
sleep(1000)
ProgressSet(84, "84 percent", "clearing temp files")
sleep(1000)
ProgressSet(86, "86 percent", "finalising..")
Cleanup()
ProgressSet(94, "94 percent", "finalising..")
sleep(800)
ProgressSet(100 , "Extension converted successfully","executing K-Meleon..")
sleep(800)
ProgressOff()
firekm()
exit
snapshots
Edited 1 time(s). Last edit at 05/27/2010 07:10AM by disrupted.