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] @ chinarobin I have a version of the macro for testing now. You can replace FavRenAdd kmm and js files with these new files. They are to be named FRA_U8.kmm and FRA_U8.js This is the simple way that I tried first which had the problem when the name and URL length were sometimes too long for the exec statement in the macro. This version does not edit the fields unless a restricted character in used in the name or the name is a duplicate of an existing name. I very much hope this lack of editing will allow the macro to work for UTF-8. FRA_U8.kmm [code] # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage) # # ---------- FRA_U8.kmm # ---------- K-Meleon Macro Language Rename/Add page to Favorites --------------- # # Dependencies : main.kmm, Favorites plugin active, JScript, Windows Scripting Host # Resources : - # Preferences : - # Version : 1.01 2008-07-19 # -------------------------------------------------------------------------------- # _FRA_U8_RnameTrue{ #### look three places for the favorites directory $_FRA_U8_FavFolder=getpref(STRING,"kmeleon.plugins.favorites.directory"); $_FRA_U8_FavFolder==""?$_FRA_U8_FavFolder=readreg("HKCU","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; $_FRA_U8_FavFolder==""?$_FRA_U8_FavFolder=readreg("HKLM","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; #### $_FRA_U8_FavFolder should have the path for the favorites folder c:\something\favorites #### call _FRA_U8_RnameTrue_loop until $_FRA_U8_SubFolder is no longer a "?" $_FRA_U8_SubFolder="?"; while($_FRA_U8_SubFolder=="?") &_FRA_U8_RnameTrue_loop; $_FRA_U8_Title = substr($_FRA_U8_value,1); macros(_FRA_U8_Sanitize_Title) ; $_FRA_U8_PathName = $_FRA_U8_FavFolder."\\".$_FRA_U8_SubFolder."\\".$_FRA_U8_Title.".url" ; $_FRA_U8_Ext_Interger = 1; while ($_FRA_U8_Ext_Interger > 0 ) &_FRA_U8_Duplicates_loop ; $_FRA_U8_Profile_Path = getfolder( ProfileFolder ); # $_fmax: The length of the command line must not exceed 258 characters! $_fmax=258; $_fcmd="(wscript.exe \"".$_FRA_U8_Path."\" \"".$_FRA_U8_PathName."\" \"".$_FRA_U8_CurURL.")" ; length($_fcmd)>$_fmax ? &_FRA_U8_Error : exec("wscript.exe \"".$_FRA_U8_Path."\" \"".$_FRA_U8_PathName."\" \"".$_FRA_U8_CurURL."\"") ; } _FRA_U8_Error{ setclipboard($_FRA_U8_Path. "\n" .$_FRA_U8_Profile_Path. "\n" .length($_fcmd) ); alert("Unable to create favorite - data too long!\n\nThe data was copied to the clipboard.","Failure to complete",EXCLAIM); } _FRA_U8_Sanitize_Title{ $_FRA_U8_RevTitle = gsub( "?"," ",$_FRA_U8_Title); $_FRA_U8_RevTitle = gsub( ":"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "*"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "<"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( ">"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "/"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "|"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "\\","",$_FRA_U8_RevTitle); $_FRA_U8_Title = gsub( "\"","^",$_FRA_U8_RevTitle); } _FRA_U8_Duplicates_loop{ $_FRA_U8_Exists=readfile($_FRA_U8_PathName); $_FRA_U8_Exists=1.$_FRA_U8_Exists ; $_FRA_U8_Len2=length($_FRA_U8_Exists); $_FRA_U8_Len2 == 1 ? $_FRA_U8_Ext_Interger=0 : &_FRA_U8_Extend; } _FRA_U8_Extend{ $_FRA_U8_Wrk_Int = $_FRA_U8_Ext_Interger - 1 ; $_FRA_U8_Ext_Interger == 1 ? $_FRA_U8_PathName = gsub(".url" , "[".$_FRA_U8_Ext_Interger."].url",$_FRA_U8_PathName):0; $_FRA_U8_Ext_Interger > 1 ? $_FRA_U8_PathName = gsub("[".$_FRA_U8_Wrk_Int."].url" , "[".$_FRA_U8_Ext_Interger."].url" , $_FRA_U8_PathName):0; $_FRA_U8_Ext_Interger = $_FRA_U8_Ext_Interger + 1 ; } _FRA_U8_RnameTrue_loop{ $_FRA_U8_SubFolder=promptforfolder("Specify where to add the new shortcut. Select your Favorites folder or one of its subfolders:",$_FRA_U8_FavFolder); $_FRA_U8_SubFolder=$_FRA_U8_SubFolder=="" ? "" : index($_FRA_U8_SubFolder,$_FRA_U8_FavFolder) == 0 ? substr($_FRA_U8_SubFolder,length($_FRA_U8_FavFolder)+1) : "?"; } _FRA_U8_RenameAdd{ $_FRA_U8_CurrTitle = $TITLE; $_FRA_U8_CurURL = $URL; $_FRA_U8_value=prompt($_FRA_U8_CurrTitle,"Rename the Favorite Title here",$_FRA_U8_CurrTitle); ### cancel from prompt will return a length of zero to which we add one $_FRA_U8_value = 1.$_FRA_U8_value; $_FRA_U8_Len=length($_FRA_U8_value); ### if the length is 1 cancelled was pressed on the prompt box $_FRA_U8_Len == 1 ? &_FRA_U8_Cancelled :&_FRA_U8_RnameTrue ; } _FRA_U8_Cancelled{ $FRA_U8_Button=confirm("Did you mean to cancel?","Affirm cancel" ,YESNO,QUESTION); $FRA_U8_Button == "YES" ? 0 : &_FRA_U8_RenameAdd ; } _FRA_U8_ModMenu{ ### add another option to Favorites menu if favorites plugin is active $kFavorites=="true"?setmenu("F&avorites",macro,"&Rename-Add-8",_FRA_U8_RenameAdd,1):0; ### show in Document Popup ; $kFavorites=="true"?setmenu("DocumentSave",macro,"&Rename-Add-8 to Favorites",_FRA_U8_RenameAdd,1):0; } _FRA_U8_GetPath{ ### FRA_U8.js is supposed to be located in the same folder as FRA_U8.kmm (this file). ### If it isn't, Windows Script Host will notify the user. $_FRA_U8_Data=readfile(getfolder(MacroFolder)."\\FRA_U8.kmm"); $_FRA_U8_Path=getfolder($_FRA_U8_Data==""?UserMacroFolder:MacroFolder)."\\FRA_U8.js"; } $OnStartup=$OnStartup."_FRA_U8_GetPath;"; $OnInit=$OnInit."_FRA_U8_ModMenu;"; $macroModules=$macroModules."FRA_U8;"; [/code] FRA_U8.js [code] /* FRA_U8.js by JamesD, version 1.01 2008-07-19 This script is a helper application for the K-Meleon Macro Module FRA_U8.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 $_FRA_U8_PathName = WScript.Arguments(0); var $_FRA_U8_CurURL = WScript.Arguments(1); var WshShell = new ActiveXObject("WScript.Shell") var oShellLink = WshShell.CreateShortcut($_FRA_U8_PathName); oShellLink.TargetPath = $_FRA_U8_CurURL; oShellLink.Save(); } 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