General :  K-Meleon Forum
General discussion about K-Meleon. 
extensions converter
Posted by: disrupted
Date: March 04, 2009 01:59AM

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 02:10PM by disrupted.

Options: ReplyQuote
Re: extensions converter
Posted by: soccerfan
Date: March 04, 2009 03:25AM

Very interesting smiling smiley
I wonder if this would get the ietab extension https://addons.mozilla.org/en-US/firefox/addon/1419 to work in km1.5.2

soccerfan

Options: ReplyQuote
Re: extensions converter
Posted by: disrupted
Date: March 04, 2009 12:54PM

no because the macro generated does not pass urls.. it's a simple macro for opening the main extension xul and checking if it can work without overlays. it will however copy the ietab jar and convert the manifest properly.

ietab can be downloaded from kmext.sf.net



Edited 1 time(s). Last edit at 05/27/2010 02:11PM by disrupted.

Options: ReplyQuote
Re: extensions converter
Posted by: soccerfan
Date: March 04, 2009 08:48PM

Thanks disrupted!

soccerfan

Options: ReplyQuote
Re: extensions converter
Posted by: guenter
Date: March 04, 2009 11:43PM

Many thanks.

Hope many will use it to test smiling smiley


p.s. Guess I will try it later today.

Options: ReplyQuote
Re: extensions converter
Posted by: Russell123
Date: May 26, 2010 05:31PM

Many thanks for this useful information it will help many people

Russell
self prep

Options: ReplyQuote
Re: extensions converter
Posted by: slayer
Date: May 27, 2010 03:34AM

Could it work with the Image Like Opera extension?

Options: ReplyQuote
Re: extensions converter
Posted by: disrupted
Date: May 27, 2010 02:09PM

unfortunately it's not ossible due to overlays, need to readapt their js separately for kmeleon and then inject

you can try policy manager extension to block images from certain domains in a custom zone, it's not the same but with sites you visit frequently it will achieve same results as 'images from originating website only'. using images from cache only is complicated and will need a thorough study of the js to know how they make images load only from cache(offline) whilst rest of the site is online

extensions converter is misleading because it doesn't really convert an extension but more like prepares the extension for further adaptation into kmeleon. in some cases it might make an extension work right away for those are quite few. now that kmeleon and mozilla are going into different paths in regards to cache, history and boomarking(sqlite) even with gecko 1.9.x kmeleons; lesser moz extensions can be ported, unless older extension release that supports ff2.0/seamonkey1.8

Options: ReplyQuote
Re: extensions converter
Posted by: disrupted
Date: May 27, 2010 07:31PM

slayer, with this we can control image load from originating website only..so will just need a simple macro to toggle the int pref, maybe in config or image context
http://kb.mozillazine.org/Permissions.default.image

affects km instantly and no restart required
still looking into the cache thing..not easy,. there doesn't seem to be a pref value for that so will need brainstorming

Options: ReplyQuote
Re: extensions converter
Posted by: disrupted
Date: May 27, 2010 09:04PM

i can't make the cache thing, so it's just from originating website only by togglin the pref
edit>configuration>image options

load and block images are just like privacy>block images toggle..so they are pointless options.. the extra one is from origin website wich will only allow images from the original website and block external images

http://kmext.sourceforge.net/macros/imgoptions.7z

it's just an easy way to access options for page display>images from the menu

Options: ReplyQuote
Re: extensions converter
Posted by: slayer
Date: May 28, 2010 02:31AM

Hi disrupted, I couldn't find the menu entry, I have the kmm (imgoptions.kmm) installed there in my macros folder, it appears in the preferences list as well.confused smiley
Is this line
setmenu("_Config_General",popup,"Image Options",8);
Where is it?


Options: ReplyQuote
Re: extensions converter
Posted by: desga2
Date: May 28, 2010 03:29AM

Hi, are you tried to change the code line in imgoptions.kmm by this?
setmenu("_Config_General",popup,"Image Options");

Without the 8 number at the end, that indicate the item position in menu.

K-Meleon in Spanish

Options: ReplyQuote
Re: extensions converter
Posted by: siria
Date: May 28, 2010 03:32AM

Hmm, no idea, and haven't tried it myself, but perhaps try with "-1" instead of "8" at the end (just wild guessing). "-1" just means add to the end of the menu, no matter how many lines it has.

But I think this would also fit very well into the privacy menu to the other blocks smiling smiley
Just replace ??macroname?? with that from "origin website" and add to the other setmenu lines:
setmenu(_Privacy_Settings,macro,"Block External Images",??macroname??,"Block F&lash");

Options: ReplyQuote
Re: extensions converter
Posted by: slayer
Date: May 28, 2010 06:31AM

OK, thanks for your replies I have the code line like this now
setmenu("_Config_General",popup,"Image Options");
But still I can not find it confused smiley

I have other macros, like 'Network Tools>Flash Video Saver','Extra Servers',etc. those work OK. Maybe there is something disabled? Does this macro relies on another one?

Options: ReplyQuote
Re: extensions converter
Posted by: desga2
Date: May 29, 2010 12:49AM

Try to add this line under the the other lines of function:
mapdom_BuildMenu{
setmenu("_Config_General",popup,"Image Options");
setmenu("Image Options",macro,"Load Images",loadallimg);
setmenu("Image Options",macro,"Block Images",blkallimg);
setmenu("Image Options",macro,"Origin Website",loadorigimg);
rebuildmenu("_Config_General");
}

K-Meleon in Spanish



Edited 1 time(s). Last edit at 05/29/2010 12:51AM by desga2.

Options: ReplyQuote
Re: extensions converter
Posted by: siria
Date: May 29, 2010 01:23AM

Well, am used to struggle with such stuff myself, so finally took a look inside:

Quote

mapdom_BuildMenu{
setmenu("_Config_General",popup,"Image Options",8);
setmenu("Image Options",macro,"Load Images",loadallimg);
setmenu("Image Options",macro,"Block Images",blkallimg);
setmenu("Image Options",macro,"Origin Website",loadorigimg);
}

$OnInit=$OnInit."imageoptions_BuildMenu;";

The problem could possibly be that the BuildMenu has not the same name cool smiley
Still think the next line would go well with it too ;-)
setmenu(_Privacy_Settings,macro,"Block External Images",loadorigimg,"Block F&lash");



Edited 1 time(s). Last edit at 05/29/2010 01:24AM by siria.

Options: ReplyQuote
Re: extensions converter
Posted by: disrupted
Date: May 29, 2010 03:10AM

sorry my mistake, i used domain mapper macro as a template when testing.
got it fixed now, please download from same link

Options: ReplyQuote
Re: extensions converter
Posted by: slayer
Date: May 29, 2010 04:17AM

Thanks @all, I'm very ashamed because the solution was so simple.smiling smiley

Options: ReplyQuote
Re: extensions converter
Posted by: disrupted
Date: May 29, 2010 04:39AM

maybe hope
http://stackoverflow.com/questions/2446740/post-loading-check-if-an-image-is-in-the-browser-cache
not sure if it will work since requires jquery, previously i had big loop problems in loading jquery in kmeleon

Options: ReplyQuote


K-Meleon forum is powered by Phorum.