home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / macros / useragent.kmm < prev    next >
Text File  |  2007-05-09  |  3KB  |  71 lines

  1. # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
  2.  
  3. # ---------- User Agent --------------------------------------------------------------------------------------------
  4. #
  5. # Dependencies    : main.kmm ($macroPrefBranch)
  6. # Resources    : -
  7. # Preferences    : kmeleon.privacy.useragent[1,2,...].name
  8. #          kmeleon.privacy.useragent[1,2,...].string
  9. #
  10. # ------------------------------------------------------------------------------------------------------------------
  11.  
  12. UserAgent{
  13. menuchecked=$ARG==""?(getpref(STRING,$_UserAgent_Active)==""):(getpref(STRING,$_UserAgent_Active)==getpref(STRING,$_UserAgent_Custom.$ARG.".string"));
  14. $ARG==""?delpref($_UserAgent_Active):$_string=getpref(STRING,$_UserAgent_Custom.$ARG.".string");
  15. $ARG==""?&_UserAgent_SyncMenu:&_UserAgent;
  16. }
  17. UserAgent_Custom{
  18. $_string=prompt(_("Enter the User Agent string to identify K-Meleon as:"),_("Custom User Agent"),getpref(STRING,$_UserAgent_Active));
  19. $_string==""?0:&_UserAgent;
  20. }
  21.  
  22. UserAgent_ToggleReset{
  23. menuchecked=getpref(BOOL,$_UserAgent_Reset);
  24. togglepref(BOOL,$_UserAgent_Reset);
  25. }
  26.  
  27. # ----- PRIVATE
  28.  
  29. $_UserAgent_Active="general.useragent.override";
  30. $_UserAgent_Custom="kmeleon.privacy.useragent";
  31. $_UserAgent_Reset=$macroPrefBranch."useragent.reset_on_exit";
  32.  
  33. _UserAgent{
  34. setpref(STRING,$_UserAgent_Active,$_string); &_UserAgent_SyncMenu;
  35. }
  36. _UserAgent_SyncMenu{
  37. $_data=getpref(STRING,$_UserAgent_Active);
  38. setcheck("macros(UserAgent_Custom)",($_data!=""));
  39. $_j=1; while($_j>0) &_UserAgent_SyncMenuLoop;
  40. }
  41. _UserAgent_SyncMenuLoop{
  42. $__data=getpref(STRING,$_UserAgent_Custom.$_j.".string");
  43. $__data==$_data?setcheck("macros(UserAgent_Custom)",false):0;
  44. $_j=$__data==""?0:$_j+1;
  45. }
  46. $OnStartup=$OnStartup."_UserAgent_SyncMenu;";
  47.  
  48. _UserAgent_BuildMenu{
  49. # tools menu
  50. $_u="&User Agent";
  51. setmenu(PrivacySecurity,popup,$_u);
  52. setmenu($_u,macro,"Default","UserAgent()");
  53. $_i=1; while($_i>0) &_UserAgent_BuildMenuLoop;
  54. setmenu($_u,macro,"&Custom...",UserAgent_Custom);
  55. setmenu($_u,macro,"&Reset To Default On Exit",UserAgent_ToggleReset);
  56. setmenu($_u,separator,"&Reset To Default On Exit");
  57. }
  58. _UserAgent_BuildMenuLoop{
  59. $__data=getpref(STRING,$_UserAgent_Custom.$_i.".name");
  60. $__data==""?0:setmenu($_u,macro,$__data,"UserAgent(".$_i.")");
  61. $_i=$__data==""?0:$_i+1;
  62. }
  63. $OnInit=$OnInit."_UserAgent_BuildMenu;";
  64.  
  65. _UserAgent_Reset{
  66. getpref(BOOL,$_UserAgent_Reset)==true?delpref($_UserAgent_Active):0;
  67. }
  68. $OnQuit=$OnQuit."_UserAgent_Reset;";
  69.  
  70. # ------------------------------------------------------------------------------------------------------------------
  71. $macroModules=$macroModules."UserAgent;";