Improvement requests
: K-Meleon Forum
Use this forum to talk about a feature you're missing. Use the bug tracker to report it if necessary.
Goto:
Forum List
•
Message List
•
Search
•
Log In
Your Name:
Subject:
Help information
BBcode help
Smileys help
[quote=JamesD] I have a new international version of FavRenAdd complete. It does not require reading of files so language should not be a factor. Many thanks must be given to kko for the large amount of help and support given to this effort. The only limitation on this version is the length of the data string passed from the K-Meleon macro to Windows Scripting Host. Web pages with very long URLs may not work. There will be an error message if this occurs. This size limit also applies to the name you give to the shortcut. [b]FavRenAdd.kmm[/b] [code] # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage) # # ---------- FavRenAdd.kmm # ---------- K-Meleon Macro Language Rename/Add page to Favorites --------------- # ---------- INTERNATIONAL VERSION # # Dependencies : - main.kmm, Favorites plugin active, JScript, Windows Scripting Host # Resources : - Registry keys "HKCU\\Software\\KMELEON\\FavRenAdd\\URLname" # and "HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc" # Preferences : - # Version : - 3.0 2008-07-30 # -------------------------------------------------------------------------------- # _FavRenAdd_RnameTrue{ #### look three places for the favorites directory $_FavRenAdd_FavFolder=getpref(STRING,"kmeleon.plugins.favorites.directory"); $_FavRenAdd_FavFolder==""?$_FavRenAdd_FavFolder=readreg("HKCU","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; $_FavRenAdd_FavFolder==""?$_FavRenAdd_FavFolder=readreg("HKLM","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; #### $_FavRenAdd_FavFolder should have the path for the favorites folder c:\something\favorites #### call _FavRenAdd_RnameTrue_loop until $_FavRenAdd_SubFolder is no longer a "?" $_FavRenAdd_SubFolder="?"; while($_FavRenAdd_SubFolder=="?") &_FavRenAdd_RnameTrue_loop; $_FavRenAdd_Title = substr($_FavRenAdd_value,1); macros(_FavRenAdd_Sanitize_Title) ; $_FavRenAdd_PathName = $_FavRenAdd_FavFolder."\\".$_FavRenAdd_SubFolder."\\".$_FavRenAdd_Title.".url" ; $_FavRenAdd_Ext_Interger = 1; while ($_FavRenAdd_Ext_Interger > 0 ) &_FavRenAdd_Duplicates_loop ; ## enclosure of a parameter in double quotes is only necessary when the parameter can contain whitespace ## therefor the 1, 2, and 3 in the next "exec" lines do not have double quotes ## first check the line lengths $_fmax=258 ; $_FavRenAdd_ExVal = 0 ; $_fcmd = "(wscript.exe \"".$_FavRenAdd_Path."\" 1 \"".$_FavRenAdd_PathName.")" ; length($_fcmd)>$_fmax ? &_FavRenAdd_Error1:0; $_fcmd = "(wscript.exe \"".$_FavRenAdd_Path."\" 2 \"".$_FavRenAdd_CurURL.")" ; length($_fcmd)>$_fmax ? &_FavRenAdd_Error2:0; $_FavRenAdd_ExVal < 2 ? &_FavRenAdd_RunScript:0; } _FavRenAdd_RunScript{ exec("wscript.exe \"".$_FavRenAdd_Path."\" 1 \"".$_FavRenAdd_PathName."\""); exec("wscript.exe \"".$_FavRenAdd_Path."\" 2 \"".$_FavRenAdd_CurURL."\""); exec("wscript.exe \"".$_FavRenAdd_Path."\" 3 \""execute"\"") ; } _FavRenAdd_Error1{ alert("Unable to create favorite - data too long! Line length, ". length($_fcmd). " and line are displayed\n\n". $_fcmd, "String length too long!", EXCLAIM) ; $_FavRenAdd_ExVal = $_FavRenAdd_ExVal + 2; } _FavRenAdd_Error2{ alert("Unable to create favorite - data too long! Line length, ". length($_fcmd). " and line are displayed\n\n". $_fcmd, "String length too long!", EXCLAIM) ; $_FavRenAdd_ExVal = $_FavRenAdd_ExVal + 3; } _FavRenAdd_Sanitize_Title{ $_FavRenAdd_RevTitle = gsub( "?"," ",$_FavRenAdd_Title); $_FavRenAdd_RevTitle = gsub( ":"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "*"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "<"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( ">"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "/"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "|"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "\\","",$_FavRenAdd_RevTitle); $_FavRenAdd_Title = gsub( "\"","^",$_FavRenAdd_RevTitle); } _FavRenAdd_Duplicates_loop{ $_FavRenAdd_Exists=readfile($_FavRenAdd_PathName); $_FavRenAdd_Exists=1.$_FavRenAdd_Exists ; $_FavRenAdd_Len2=length($_FavRenAdd_Exists); $_FavRenAdd_Len2 == 1 ? $_FavRenAdd_Ext_Interger=0 : &_FavRenAdd_Extend; } _FavRenAdd_Extend{ $_FavRenAdd_Wrk_Int = $_FavRenAdd_Ext_Interger - 1 ; $_FavRenAdd_Ext_Interger == 1 ? $_FavRenAdd_PathName = gsub(".url" , "[".$_FavRenAdd_Ext_Interger."].url",$_FavRenAdd_PathName):0; $_FavRenAdd_Ext_Interger > 1 ? $_FavRenAdd_PathName = gsub("[".$_FavRenAdd_Wrk_Int."].url" , "[".$_FavRenAdd_Ext_Interger."].url" , $_FavRenAdd_PathName):0; $_FavRenAdd_Ext_Interger = $_FavRenAdd_Ext_Interger + 1 ; } _FavRenAdd_RnameTrue_loop{ $_FavRenAdd_SubFolder=promptforfolder("Specify where to add the new shortcut. Select your Favorites folder or one of its subfolders:",$_FavRenAdd_FavFolder); $_FavRenAdd_SubFolder=$_FavRenAdd_SubFolder=="" ? "" : index($_FavRenAdd_SubFolder,$_FavRenAdd_FavFolder) == 0 ? substr($_FavRenAdd_SubFolder,length($_FavRenAdd_FavFolder)+1) : "?"; } _FavRenAdd_RenameAdd{ $_FavRenAdd_CurrTitle = $TITLE; $_FavRenAdd_CurURL = $URL; $_FavRenAdd_value=prompt($_FavRenAdd_CurrTitle,"Rename the Favorite Title here",$_FavRenAdd_CurrTitle); ### cancel from prompt will return a length of zero to which we add one $_FavRenAdd_value = 1.$_FavRenAdd_value; $_FavRenAdd_Len=length($_FavRenAdd_value); ### if the length is 1 cancelled was pressed on the prompt box $_FavRenAdd_Len == 1 ? &_FavRenAdd_Cancelled :&_FavRenAdd_RnameTrue ; } _FavRenAdd_Cancelled{ $FavRenAdd_Button=confirm("Did you mean to cancel?","Affirm cancel" ,YESNO,QUESTION); $FavRenAdd_Button == "YES" ? 0 : &_FavRenAdd_RenameAdd ; } _FavRenAdd_ModMenu{ ### add another option to Favorites menu if favorites plugin is active $kFavorites=="true"?setmenu("F&avorites",macro,"&Rename-Add",_FavRenAdd_RenameAdd,1):0; ### show in Document Popup ; $kFavorites=="true"?setmenu("DocumentSave",macro,"&Rename-Add to Favorites",_FavRenAdd_RenameAdd,1):0; } _FavRenAdd_GetPath{ ### FavRenAdd.js is supposed to be located in the same folder as FavRenAdd.kmm (this file). ### If it isn't, Windows Script Host will notify the user. $_FavRenAdd_Data=readfile(getfolder(MacroFolder)."\\FavRenAdd.kmm"); $_FavRenAdd_Path=getfolder($_FavRenAdd_Data==""?UserMacroFolder:MacroFolder)."\\FavRenAdd.js"; } $OnStartup=$OnStartup."_FavRenAdd_GetPath;"; $OnInit=$OnInit."_FavRenAdd_ModMenu;"; $macroModules=$macroModules."FavRenAdd;"; [/code] [b]FavRenAdd.js[/b] [code] /* FavRenAdd.js by JamesD, version 3.01 2008-07-30 INTERNATIONAL VERSION This script is a helper application for the K-Meleon Macro Module FavRenAdd.kmm that enables you to rename a favorite, select a folder, and write the favorite to that folder. Windows Script Host 1.0 (or better) required! WSH is part of Microsoft Internet Explorer 5.0 and newer. Latest version of WSH is available at http://msdn.microsoft.com/scripting/ */ if(WScript.Arguments.count()==2) { var WshShell = new ActiveXObject("WScript.Shell") if (WScript.Arguments(0) == 1) { WshShell.RegWrite ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLname", WScript.Arguments(1), "REG_SZ"); } if (WScript.Arguments(0) == 2) { WshShell.RegWrite ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc", WScript.Arguments(1), "REG_SZ"); } if (WScript.Arguments(0) == 3) { WScript.Sleep(1000); var $_FavRenAdd_PathName = WshShell.RegRead ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLname") ; var $_FavRenAdd_CurURL = WshShell.RegRead ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc") ; var oShellLink = WshShell.CreateShortcut($_FavRenAdd_PathName); oShellLink.TargetPath = $_FavRenAdd_CurURL; oShellLink.Save(); WshShell.RegDelete ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLname") ; WshShell.RegDelete ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc") ; } } else { objArgs = WScript.Arguments ; WScript.Echo(WScript.Arguments.Count()); for (i=0; i<objArgs.length; i++) { WScript.Echo(objArgs(i)) } } [/code][/quote]
[Please Enable JavaScript]
K-Meleon forum is powered by
Phorum
.
Home/News
Screenshots
Download
Documentation
Resources
Get Involved
Forum
Bugs
Development