# Greasify 0.7.1.9.20071028(http://www.digivill.net/~joykillr/kmeleon/kmeleon_userscripts.html) # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage) # ---------- Greasify Macro ------------------------------------------------------------------------------------ # # Dependencies : main.kmm ($macroPrefBranch, JS) # Resources : - # Preferences : kmeleon.plugins.macros.greasify # kmeleon.plugins.macros.greasify.userscript[1-99] # kmeleon.plugins.macros.greasify.scripts.active # kmeleon.plugins.macros.greasify.scripts.values # # ------------------------------------------------------------------------------------------------------------------ ###########GREASIFY############# $_Greasify_Custom=$macroPrefBranch."greasify"; Greasify{ $LOCALPATH = getpref(STRING,$_Greasify_Custom.".directory"); $howmany = 8; $scripts = ""; $includeURL = ""; $excludeURL = ""; $HOST = hostname( $URL ); $hostlength = length($HOST); $xtotal = getpref(INT,$_Greasify_Custom.".scripttotal"); $xmain = 1; $hostlength==0 ? $xmain = 99:0; $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); $activeURL = $URL; $schmchk = ""; $schmidx = 0; $schmidx = index($activeURL,"\:\/\/"); $schmchk = $schmidx>0 ? substr($activeURL,0,$schmidx): $schmchk; $xnameLEN = index($schmchk,"tp")>0? $xnameLEN : 0; $nscompat = getpref(BOOL,$_Greasify_Custom.".nscompat"); $nscompat==true?$siteAllowed = getpref(STRING, "capability.policy.maonoscript.sites"):0; $nscompat==true?$nsGlobalReady = getpref(BOOL,"noscript.global"):0; while ($xnameLEN != 0) &GreasifyCodeChkNEW; setpref(STRING,$_Greasify_Custom.".scripts.active", $scripts); } GreasifyCodeChkNEW{ $z = 0; $NS = getpref(STRING,$_Greasify_Custom.".userscript".$xmain.".name"); $QQe = getpref(INT,$_Greasify_Custom.".userscript".$xmain.".exclude.total"); $Qq = 1; while ($Qq <= $QQe) &GreasifyCodeChkNEWExcludes; $includeURL = ""; $QQi = getpref(INT,$_Greasify_Custom.".userscript".$xmain.".include.total"); $Qq = 1; $QQi = $z>0? 0 : $QQi; $z = 0; while ($Qq <= $QQi) &GreasifyCodeChkNEWIncludes; $nsChk = $nscompat==true ? index($siteAllowed, " ".$HOST." ") : -1; $z>=1 ? &GreasifyNewInjectJS:0; $xmain = $xmain + 1; $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); } GreasifyCodeChkNEWIncludes{ $strAeval = -1; $ftpEval = -1; $secEval = -1; $strStartLoc = -1; $includeURL = ""; $includeURL = getpref(STRING,$_Greasify_Custom.".userscript".$xmain.".include.".$Qq); &GHostChkSevenAssist2; } GreasifyCodeChkNEWExcludes{ $strAeval = -1; $ftpEval = -1; $secEval = -1; $strStartLoc = -1; $excludeURL = ""; $excludeURL = getpref(STRING,$_Greasify_Custom.".userscript".$xmain.".exclude.".$Qq); &GExcludeAssist2; } GExcludeChk{ &GExcludeChk1; &GExcludeChk2; } GreasifyInjectJS{ $nscompat!=true ? 0 : $nsChk!=-1 ? 0 : $nsGlobalReady==true ? 0 : &GreasifyNoScriptCompatApplyOn; injectJS($con2); $nscompat!=true ? 0 : $nsChk!=-1 ? 0 : $nsGlobalReady==true ? 0 : &GreasifyNoScriptCompatApplyOff; $sbgo = getpref(INT,$_Greasify_Custom.".statusbarmsg"); #$sbx = $z>=1 ? $sbgo!=-1 ? $sbgo!=0 ? 1:0; ##$z>=1 ? $sbgo!=-1 ? $sbgo!=0 ? $sbx = 1 : $sbx = 0; ##$sbx==1 ? statusbar("***Userscript Applied: ".$NS) : $sbx = $sbx; ##$z>=1 ? $scripts = $scripts."\n\n".$NS." \(".$xname."\)"."\n": $scripts = $scripts; ####$z>=1 ? $sbgo >=1 ? $sbx = 1 : $sbx = 0; ####$sbx==1 ? statusbar("***Userscript Applied: ".$NS) : $sbx = $sbx; $z<1 ? $sbgo<1 ? $z = $z : statusbar("***Userscript Applied: ".$NS); ###$z<1?$z=$z : $sbgo==-1?$sbgo=$sbgo : $sbgo==0?$sbx = 0 : $sbx = 1; ###$sbx!=1 ? $sbx = $sbx : statusbar("\*\*\*Userscript Applied\: ".$NS); #$z>=1? $scripts = $scripts."\n\n".$NS." \(".$xname."\)"."\n" : $scripts = $scripts; $z>=1? $scripts = $scripts."\n\n".$NS." \(".$xname."\)"."\n" : $z = $z; $vchk = ""; $vchk = getpref(BOOL,$_Greasify_Custom.".copyclipboard"); $vchk==true ? setclipboard($con2) : 0; } GCChk2{ $checkBeginning = ""; $checkEnding = ""; $hstrun = "\^".$hstrun; $checkBeginning = index($hstrun,"\^\*"); $checkBeginning!=-1? $hstrun = gsub("\^\*.", "", $hstrun):0; $checkBeginning!=-1? $hstrun = gsub("\^\*", "", $hstrun):0; $checkBeginning==-1? $hstrun = substr($hstrun,1):0; $gocount = 6; $checkEnding = 0; $USidx = length($hstrun); $USidx = $USidx - 1; length($hstrun)<1? $gocount = 0:0; $checkBeginning!=-1? $checkBeginning = 1:0; #$USidx>0? while ($gocount > 0) &GreasifyHostCheckHelper:0; $USidx>0? $atest = "TRUE" : $atest = "FALSE"; ##while ($atest = "TRUE") &GreasifyHostCheckHelperK15; $atest=="TRUE"? &GreasifyHostCheckHelperK15 : $atest = $atest; $checkBeginning!=1? 0 : $checkEnding!=1? 0 : $theMeth = "BeginStarEndStar"; $checkBeginning!=1? 0 : $checkEnding==1? 0 : $theMeth = "BeginStarEnd"; $checkBeginning==1? 0 : $checkEnding==1? 0 : $theMeth = "BeginEnd"; $checkBeginning==1? 0 : $checkEnding!=1? 0 : $theMeth = "BeginEndStar"; $thirdStar = index($hstrun,"\*")!=-1 ? "true" : "false"; $activeURLsecEval = -1; $activeURLftpEval = -1; $activeURLeval = -1; $activeSecEvalIndex = -1; $activeftpEvalIndex = -1; $activeURLeval = index($activeURL, "http:\/\/"); $activeSecEvalIndex = index($activeURL, "https:\/\/"); $activeftpEvalIndex = index($activeURL, "ftp:\/\/"); $activeURLeval==-1 ? $activeURLsecEval = $activeSecEvalIndex:0; $activeURLeval!=-1 ? 0 : $activeURLsecEval!=-1 ? 0 : $activeURLftpEval = $activeftpEvalIndex; $activeURLeval!=-1? $activeURLStartLoc = $activeURLeval + 7:0; $activeURLsecEval!=-1? $activeURLStartLoc = $activeURLsecEval + 8:0; $activeURLftpEval!=-1? $activeURLStartLoc = $activeURLftpEval + 6:0; $activeURLeval==-1? 0 : $strAeval==-1? 0 : $thirdStar=="true"? 0:&gEvalAll; $activeURLeval==-1? 0 : $strAeval==-1? 0 : $thirdStar=="false"? 0:&gEvalAllAlt; $activeURLsecEval==-1? 0 : $secEval==-1? 0 : $thirdStar=="true"? 0:&gEvalAll; $activeURLsecEval==-1? 0 : $secEval==-1? 0 : $thirdStar=="false"? 0:&gEvalAllAlt; $activeURLftpEval==-1? 0 : $ftpEval==-1? 0 : $thirdStar=="true"? 0:&gEvalAll; $activeURLftpEval==-1? 0 : $ftpEval==-1? 0 : $thirdStar=="false"? 0:&gEvalAllAlt; } GreasifyHostCheckHelperK15{ while ($gocount > 0) &GreasifyHostCheckHelper; $atest = "FALSE"; } gEvalAll{ $activeURLLength = length($activeURL); $hstrunLength = length($hstrun); $theMeth=="BeginStarEndStar" ? &gEvalAll_BeginStarEndStar : 0; $theMeth=="BeginEndStar" ? &gEvalAll_BeginEndStar : 0; $theMeth=="BeginStarEnd" ? &gEvalAll_BeginStarEnd : 0; $theMeth=="BeginEnd" ? &gEvalAll_BeginEnd : 0; } gEvalAll_BeginStarEndStar{ $z = index($activeURL, $hstrun)!=-1 ? 1 : $z; } gEvalAll_BeginEndStar{ $activeURL = substr($activeURL, $activeURLStartLoc); $activeURL = substr($activeURL,0,$hstrunLength); $z = $activeURL==$hstrun ? 1 : $z ; } gEvalAll_BeginStarEnd{ $activeURL = substr($activeURL, $activeURLStartLoc); $activeURLLength>$hstrunLength? $activeURLLength = $activeURLLength - $hstrunLength:0; $activeURLLength>$hstrunLength? $activeURL = substr($activeURL, $activeURLLength):0; $activeURLLength<$hstrunLength? $hstrunLength = $hstrunLength - $activeURLLength:0; $activeURLLength<$hstrunLength? $hstrun = substr($hstrun, $hstrunLength):0; $z = $activeURL==$hstrun ? 1 : $z ; } gEvalAll_BeginEnd{ $activeURL = substr($activeURL, $activeURLStartLoc); $z = $activeURL==$hstrun ? 1 : $z ; } gEvalAllAlt{ $midIDX = index($hstrun,"\*"); $mid1 = substr($hstrun,0,$midIDX); $midIDX = $midIDX + 1; $mid2 = substr($hstrun,$midIDX); $mid1Length = length($mid1); $mid2Length = length($mid2); $activeURLLength = length($activeURL); $hstrunLength = length($hstrun); $theMeth=="BeginStarEndStar" ? gEvalAllAlt_BeginStarEndStar:0; $theMeth=="BeginEndStar" ? gEvalAllAlt_BeginEndStar:0; $theMeth=="BeginStarEnd" ? gEvalAllAlt_BeginStarEnd:0; $theMeth=="BeginEnd" ? gEvalAllAlt_BeginEnd:0; } gEvalAllAlt_BeginStarEndStar{ index($activeURL, $mid1)!=-1 ? index($activeURL, $mid2)!=-1 ? $z = 1 : $z = $z; } gEvalAllAlt_BeginEndStar{ $activeURLa = substr($activeURL,0,$mid1Length); $activeURLa==$mid1 ? index($activeURL, $mid2)!=-1 ? $z = 1 : $z = $z; } gEvalAllAlt_BeginStarEnd{ $activeURLLength = $activeURLLength - $mid2Length:0; $activeURLb = substr($activeURL,$activeURLLength,$mid2Length):0; $activeURLb==$mid2 ? index($activeURL, $mid1)!=-1 ? $z = 1 : $z = $z; } gEvalAllAlt_BeginEnd{ $activeURLa = substr($activeURL,0,$mid1Length):0; $activeURLLength = $activeURLLength - $mid2Length:0; $activeURLb = substr($activeURL,$activeURLLength,$mid2Length):0; $activeURLa==$mid1 ? $activeURLb==$mid2 ? $z = 1 : $z = $z; } GreasifyHostCheckHelper{ $hstrunvchk = ""; $checkEnding = 0; $USidx = $USidx - 1; $hstrunvchk = substr($hstrun, $USidx); $chkHstRun = index($hstrunvchk,"\.\*"); $chkHstRun = index($hstrunvchk,"\/\*"); $USidx = $USidx + 1; $hstrunvchk = substr($hstrun, $USidx,1); $chkHstRun!=-1 ? $USidx = $USidx - 1:0; $hstrunvchk=="\*" ? $hstrun = substr($hstrun, 0, $USidx):0; $hstrunvchk=="\*" ? $checkEnding = 1:0; $hstrunvchk=="\*" ? $gocount = 0:0; $gocount>0 ? $gocount = $gocount - 1:0; $USidx = $USidx - 1; } GHostChkSeven{ &GHostChkSeven1; &GHostChkSeven2; } GHostChkSeven1{ $strAeval = -1; $ftpEval = -1; $secEval = -1; $strStartLoc = -1; $includeURL1st = ""; $includeURL2nd = ""; $includeURL3rd = ""; $includeURL4th = ""; $includeURL5th = ""; $includeURL6th = ""; $includeURL7th = ""; $includeURL8th = ""; $includeURL = ""; $includeAgain = -1; $includeTotal = -1; $exChk2 = index($includeURLs,"\/\/\ \@exclude"); $exChk2>0? $includeURLs = substr($includeURLs,0,$exChk2):0; #$includeURLs = $exChk2>0? substr($includeURLs,0,$exChk2):$includeURLs; $includeAgain = index($includeURLs,"\/\/\ \@include"); $includeURL1st = $includeAgain!=-1 ? substr($includeURLs,$includeAgain+11):$includeURL1st; $includeTotal = $includeURL1st!= "" ? 1:$includeTotal; $includeAgain = index($includeURL1st,"\/\/\ \@include"); $includeURL2nd = $includeAgain!=-1 ? substr($includeURL1st,$includeAgain+11):$includeURL2nd; $includeTotal = $includeAgain!=-1? 2 : $includeTotal; $includeURL1st = $includeAgain!=-1 ? substr($includeURL1st,0,$includeAgain) : $includeURL1st; $includeAgain = index($includeURL2nd,"\/\/ @include"); $includeURL3rd = $includeAgain!=-1 ? substr($includeURL2nd,$includeAgain+11):$includeURL3rd; $includeTotal = $includeAgain!=-1? 3 : $includeTotal; $includeURL2nd = $includeAgain!=-1 ? substr($includeURL2nd,0,$includeAgain) : $includeURL2nd; $includeAgain = index($includeURL3rd,"\/\/ @include"); $includeURL4th = $includeAgain!=-1 ? substr($includeURL3rd,$includeAgain+11):$includeURL4th; $includeTotal = $includeAgain!=-1? 4 : $includeTotal; $includeURL3rd = $includeAgain!=-1 ? substr($includeURL3rd,0,$includeAgain) : $includeURL3rd; $includeAgain = index($includeURL4th,"\/\/ @include"); $includeURL5th = $includeAgain!=-1 ? substr($includeURL4th,$includeAgain+11):$includeURL5th; $includeTotal = $includeAgain!=-1? 5 : $includeTotal; $includeURL4th = $includeAgain!=-1 ? substr($includeURL4th,0,$includeAgain) : $includeURL4th; $includeAgain = index($includeURL5th,"\/\/ @include"); $includeURL6th = $includeAgain!=-1 ? substr($includeURL5th,$includeAgain+11):$includeURL6th; $includeTotal = $includeAgain!=-1? 6 : $includeTotal; $includeURL5th = $includeAgain!=-1 ? substr($includeURL5th,0,$includeAgain) : $includeURL5th; $includeAgain = index($includeURL6th,"\/\/ @include"); $includeURL7th = $includeAgain!=-1 ? substr($includeURL6th,$includeAgain+11):$includeURL7th; $includeTotal = $includeAgain!=-1? 7 : $includeTotal; $includeURL6th = $includeAgain!=-1 ? substr($includeURL6th,0,$includeAgain) : $includeURL6th; $includeAgain = index($includeURL7th,"\/\/ @include"); $includeURL8th = $includeAgain!=-1 ? substr($includeURL7th,$includeAgain+11):$includeURL8th; $includeTotal = $includeAgain!=-1? 8 : $includeTotal; $includeURL7th = $includeAgain!=-1 ? substr($includeURL7th,0,$includeAgain) : $includeURL7th; } GHostChkSeven2{ $Qq = 1; while ($Qq <= $includeTotal) &GHostChkSevenAssist; } GHostChkSevenAssist{ &GHostChkSevenAssist1; &GHostChkSevenAssist2; } GHostChkSevenAssist1{ $more = -1; $includeURL = $Qq==1? $includeURL1st : $includeURL; $includeURL = $Qq==2? $includeURL2nd : $includeURL; $includeURL = $Qq==3? $includeURL3rd : $includeURL; $includeURL = $Qq==4? $includeURL4th : $includeURL; $includeURL = $Qq==5? $includeURL5th : $includeURL; $includeURL = $Qq==6? $includeURL6th : $includeURL; $includeURL = $Qq==7? $includeURL7th : $includeURL; $includeURL = $Qq==8? $includeURL8th : $includeURL; } GHostChkSevenAssist2{ &GChkSevenProcessor; $activeURL = $URL; $activeURL = gsub("\n","",$activeURL); $activeURL = gsub("\t","",$activeURL); &GCChk2; $Qq = $z>=1 ? $QQi + 1: $Qq + 1; } GChkSevenProcessor{ $strAeval = index($includeURL, "http:\/\/"); $secEvalIndex = index($includeURL, "https:\/\/"); $strAeval==-1 ? $secEval = $secEvalIndex:0; $ftpEvalIndex = index($includeURL, "ftp:\/\/"); $strAeval!=-1 ? 0 : $secEval!=-1 ? 0 : $ftpEval = $ftpEvalIndex; $strAeval!=-1? $strStartLoc = $strAeval + 7:0; $secEval!=-1? $strStartLoc = $secEval + 8:0; $ftpEval!=-1? $strStartLoc = $ftpEval + 6:0; $strStartLoc!=-1? $includeURL = substr($includeURL, $strStartLoc):0; #$includeURL = $strStartLoc!=-1? substr($includeURL, $strStartLoc):$includeURL; $more = index($includeURL, "\/\/\ "); $includeURL = $more>=1 ? substr($includeURL,0,$more) : $includeURL; $hstrun = $includeURL; } GExcludeChk1{ $strAeval = -1; $ftpEval = -1; $secEval = -1; $strStartLoc = -1; $excludeURL1st = ""; $excludeURL2nd = ""; $excludeURL3rd = ""; $excludeURL4th = ""; $excludeURL = ""; $excludeAgain = -1; $excludeTotal = -1; $exChk1 = index($excludeURLs,"\/\/\ \@include"); $exChk1>0? $excludeURLs = substr($excludeURLs,0,$exChk1):0; $excludeAgain = index($excludeURLs,"\/\/\ \@exclude"); $excludeURL1st = $excludeAgain!=-1 ? substr($excludeURLs,$excludeAgain+11):$excludeURL1st; $excludeTotal = $excludeURL1st!= "" ? 1:$excludeTotal; $excludeAgain = index($excludeURL1st,"\/\/\ \@exclude"); $excludeURL2nd = $excludeAgain!=-1 ? substr($excludeURL1st,$excludeAgain+11):$excludeURL2nd; $excludeTotal = $excludeAgain!=-1? 2 : $excludeTotal; $excludeURL1st = $excludeAgain!=-1 ? substr($excludeURL1st,0,$excludeAgain) : $excludeURL1st; $excludeAgain = index($excludeURL2nd,"\/\/ \@exclude"); $excludeURL3rd = $excludeAgain!=-1 ? substr($excludeURL2nd,$excludeAgain+11):$excludeURL3rd; $excludeTotal = $excludeAgain!=-1? 3 : $excludeTotal; $excludeURL2nd = $excludeAgain!=-1 ? substr($excludeURL2nd,0,$excludeAgain) : $excludeURL2nd; $excludeAgain = index($excludeURL3rd,"\/\/ \@exclude"); $excludeURL4th = $excludeAgain!=-1 ? substr($excludeURL3rd,$excludeAgain+11):$excludeURL4th; $excludeTotal = $excludeAgain!=-1? 4 : $excludeTotal; $excludeURL3rd = $excludeAgain!=-1 ? substr($excludeURL3rd,0,$excludeAgain) : $excludeURL3rd; } GExcludeChk2{ $Qq = 1; while ($Qq <= $excludeTotal) &GExcludeAssist; $stop = $z>0 ? 1 : 0; $z = 0; $includeURL = ""; } GExcludeAssist{ &GExcludeAssist1; &GExcludeAssist2; } GExcludeAssist1{ $more = -1; $excludeURL = $Qq==1? $excludeURL1st : $excludeURL; $excludeURL = $Qq==2? $excludeURL2nd : $excludeURL; $excludeURL = $Qq==3? $excludeURL3rd : $excludeURL; $excludeURL = $Qq==4? $excludeURL4th : $excludeURL; } GExcludeAssist2{ $includeURL = $excludeURL; &GChkSevenProcessor; $activeURL = $URL; $activeURL = gsub("\n","",$activeURL); $activeURL = gsub("\t","",$activeURL); &GCChk2; $Qq = $Qq + 1; } GreasifyDelScript{ &GreasifyScriptsActive; $scrnum = prompt("Enter the number of the script you wish to remove:", "Select Script To Remove", ""); $scrnum!="" ? $scrtodel = getpref(STRING,$_Greasify_Custom.".userscript".$scrnum):$scrtodel = ""; $scrnum!="" ? $confdel = confirm("Are you sure you wish to remove ".$scrtodel."?", "Remove Script from Repository?", YESNO, QUESTION):$confdel = "NO"; $confdel=="YES" ? &GreasifyDelScriptCont:0; } GreasifyDelScriptCont{ $xmain = $count; &GreasifyClearIncExcPrefsProc; $xmain = $scrnum; $scrnum==$count? 0 : &GreasifyClearIncExcPrefsProc; statusbar("Done clearing include/exclude URLs."); $scrtomov = getpref(STRING,$_Greasify_Custom.".userscript".$count); setpref(STRING,$_Greasify_Custom.".userscript".$scrnum, $scrtomov); setpref(STRING,$_Greasify_Custom.".userscript".$count, ""); $count = $count - 1; setpref(INT,$_Greasify_Custom.".scripttotal", $count); $xmain = $scrnum; &GreasifyAddScriptPrefsGen; } GreasifySetDir{ $FOLDERPATH = promptforfolder("Select Folder Containing User Scripts"); $FOLDERPATH=="" ? 0 : setpref(STRING,$_Greasify_Custom.".directory", $FOLDERPATH); } GreasifyScriptsActive{ $un = 1; $count = getpref(INT,$_Greasify_Custom.".scripttotal"); $scripts = ""; $workpref = getpref(STRING,$_Greasify_Custom.".userscript1"); $preflen = length($workpref); while ($preflen != 0) &GreasifyScriptsActiveHelp; alert($scripts, "Userscripts In Repository", INFO); } GreasifyScriptsActiveHelp{ $workpref = getpref(STRING,$_Greasify_Custom.".userscript".$un); $preflen = length($workpref); $nm = getpref(STRING,$_Greasify_Custom.".userscript".$un.".name"); $scripts = $scripts."\n".$un.". ".$nm."\t"."((".$workpref."))"; #length($workpref)<=0 ? $preflen = 0:$un = $un + 1; $preflen<=0 ? $preflen = 0:$un = $un + 1; $workpref = getpref(STRING,$_Greasify_Custom.".userscript".$un); $preflen = length($workpref); } GreasifySetScripts{ $FOLDERPATH = getpref(STRING,$_Greasify_Custom.".directory"); $foldlen = length($FOLDERPATH); $FILEPATH = promptforfile($FOLDERPATH,"User Script Files","*.user.js"); $filelen = length($FILEPATH); $un = 1; $workpref = getpref(STRING,$_Greasify_Custom.".userscript".$un); $preflen = length($workpref); while ($preflen >= 1) &GreasifySetScriptsHelp; $foldlen = $filelen - $foldlen; $filelen = $filelen - $foldlen; $filelen = $filelen + 1; $FILEPATH = substr($FILEPATH, $filelen); length($FILEPATH)>1 ? $RESULT = confirm("Confirm addition of userscript ".$FILEPATH."?", $FILEPATH, YESNO, QUESTION):$RESULT = "NO"; $RESULT == "YES" ? &GreasifySetScrCont:0; } GreasifySetScrCont{ setpref(STRING,$_Greasify_Custom.".userscript".$un, $FILEPATH); setpref(INT,$_Greasify_Custom.".scripttotal", $un); $xmain = $un; &GreasifyClearIncExcPrefsProc; statusbar("Done clearing include/exclude URL."); $xmain = $un; &GreasifyAddScriptPrefsGen; } GreasifySetScriptsHelp{ $workpref = getpref(STRING,$_Greasify_Custom.".userscript".$un); $preflen = length($workpref); length($workpref)<=0 ? $preflen = 0:$un = $un + 1; } GreasifyToggle{ ##$VALUE = getpref(INT,$_Greasify_Custom.".enabled"); ##$VALUE==0 ? setpref(INT,$_Greasify_Custom.".enabled",1):setpref(INT,$_Greasify_Custom.".enabled",0); ##$VALUE==0 ? statusbar("Greasify Enabled"):statusbar("Greasify Disabled"); #getpref(INT,$_Greasify_Custom.".enabled")!=1 ? setpref(BOOL,$_Greasify_Custom.".enablednew",FALSE):setpref(BOOL,$_Greasify_Custom.".enablednew",TRUE); $dtest = ""; $dtest2 = ""; togglepref(BOOL,$_Greasify_Custom.".enablednew"); $dtest = getpref(BOOL, $_Greasify_Custom.".enablednew"); #alert("toggle"."\n\n".$dtest,"123",INFO); $dtest=="" ? $dtest = true : $dtest = $dtest; #setpref(BOOL,$_Greasify_Custom.".enablednew",$dtest); $dtest==true ? $dtest2 = "Greasify Enabled": $dtest2 = $dtest2; $dtest==false ? $dtest2 = "Greasify Disabled": $dtest2 = $dtest2; statusbar($dtest2); menuchecked=getpref(BOOL,$_Greasify_Custom.".enablednew"); } GreasifySBToggle{ $VALUE = getpref(INT,$_Greasify_Custom.".statusbarmsg"); $VALUE==0 ? setpref(INT,$_Greasify_Custom.".statusbarmsg", 1):setpref(INT,$_Greasify_Custom.".statusbarmsg", 0); $VALUE==0 ? statusbar("Greasify Status-bar Notification Disabled"):statusbar("Greasify Status-bar Notification Enabled"); getpref(INT,$_Greasify_Custom.".statusbarmsg")!=1 ? setpref(BOOL,$_Greasify_Custom.".statbarnew",TRUE):setpref(BOOL,$_Greasify_Custom.".statbarnew",FALSE); menuchecked=getpref(BOOL,$_Greasify_Custom.".statbarnew"); } GreasifyScriptsApplied{ $scriptsactive = getpref(STRING,$_Greasify_Custom.".scripts.active"); alert($scriptsactive,"Userscripts Applied to the Current Page",INFO); } Greasify_AddStyle{ $con2 = $con2."\n\n"."function GM_addStyle(css) {var head = document.getElementsByTagName('head')[0]; if (!head) { return; } var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style);}"."\n"; } GreasifyApplyNow{ &Greasify; } GreasifyExportScriptList{ $un = 1; $count = getpref(INT,$_Greasify_Custom.".scripttotal"); $scripts = ""; $workpref = getpref(STRING,$_Greasify_Custom.".userscript1"); $preflen = length($workpref); while ($preflen != 0) &GreasifyScriptsActiveHelp; $scripts = gsub("\n1.", "Greasify User Script List \n1. ", $scripts); setclipboard($scripts); } GreasifyViewScript{ $scrnum = ""; $LOCALPATH = getpref(STRING,$_Greasify_Custom.".directory"); &GreasifyScriptsActive; $scrnum = prompt("Enter script number to view:", "View Script - Selection", ""); $scrnum!="" ? &GreasifyViewScript2:0; $scrnum!="" ? open($scrtoView):0; } GreasifyViewScript2{ $scrtoView = getpref(STRING,$_Greasify_Custom.".userscript".$scrnum); $scrtoView = $LOCALPATH."\\".$scrtoView; $scrtoView = gsub("\\", "\/", $scrtoView); $scrtoView = "file\:\/\/\/".$scrtoView; } GreasifyVerifyScript{ $vchk = ""; $vchk = getpref(BOOL,$_Greasify_Custom.".copyclipboard"); $vchk==false ? setpref(BOOL,$_Greasify_Custom.".copyclipboard",TRUE) : setpref(BOOL,$_Greasify_Custom.".copyclipboard",FALSE); menuchecked=getpref(BOOL,$_Greasify_Custom.".copyclipboard"); } GreasifyNoScriptCompat{ togglepref(BOOL,$_Greasify_Custom.".nscompat"); menuchecked=getpref(BOOL,$_Greasify_Custom.".nscompat"); } GreasifyNoScriptCompatApplyOn{ setpref(STRING,"capability.policy.default.javascript.enabled","allAccess"); setpref(BOOL,"noscript.global","true"); } GreasifyNoScriptCompatApplyOff{ setpref(STRING,"capability.policy.default.javascript.enabled","noAccess"); setpref(BOOL,"noscript.global","false"); } GreasifyClearIncExcPrefs{ $xmain = 1; $xtotal = getpref(INT,$_Greasify_Custom.".scripttotal"); $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); while ($xnameLEN != 0) &GreasifyClearIncExcPrefsProc; statusbar("Done clearing include/exclude URLs."); } GreasifyClearIncExcPrefsProc{ statusbar("Clearing URLs for userscript ".$xmain); $QQe = getpref(INT,$_Greasify_Custom.".userscript".$xmain.".exclude.total"); $rcnt = 1; while ($rcnt <= $QQe) &GreasifyClearExcludes; setpref(INT,$_Greasify_Custom.".userscript".$xmain.".exclude.total",0); #setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".exclude.string",""); $QQi = getpref(INT,$_Greasify_Custom.".userscript".$xmain.".include.total"); $rcnt = 1; while ($rcnt <= $QQi) &GreasifyClearIncludes; setpref(INT,$_Greasify_Custom.".userscript".$xmain.".include.total",0); #setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".include.string",""); setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".name",""); $xmain = $xmain + 1; $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); } GreasifyClearIncludes{ setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".include.".$rcnt,""); $rcnt = $rcnt + 1; } GreasifyClearExcludes{ setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".exclude.".$rcnt,""); $rcnt = $rcnt + 1; } GreasifyAddScriptPrefsGen{ $LOCALPATH = getpref(STRING,$_Greasify_Custom.".directory"); $howmany = 8; $scripts = ""; $excludeTotal = 0; $includeTotal = 0; &GreasifyGenIncExcProcessor; $xmain = $xmain - 1; $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); statusbar("Done processing include/exclude URLs for ".$xname."."); } GreasifyGenerateAllInOne{ &GreasifyClearIncExcPrefs; &GreasifyGenerateIncExcPrefs; } GreasifyGenerateIncExcPrefs{ $LOCALPATH = getpref(STRING,$_Greasify_Custom.".directory"); $howmany = 8; $scripts = ""; $excludeTotal = 0; $includeTotal = 0; $xtotal = getpref(INT,$_Greasify_Custom.".scripttotal"); $xmain = 1; $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); while ($xnameLEN != 0) &GreasifyGenIncExcProcessor; statusbar("Done processing include/exclude URLs."); } GreasifyGenIncExcProcessor{ statusbar("Processing URLs for userscript ".$xmain); &GreasifyProcessHeader; $NS = gsub("\n","",$NS);$NS = gsub("\t","",$NS); $NS==""?0:&GreasifyNameGenHelp; $NS==""?setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".name","--unnamed--"):setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".name",$NS); $excIdx>0 ? &GExcludeChk1:0; &GHostChkSeven1; $excIdx>0 ? setpref(INT,$_Greasify_Custom.".userscript".$xmain.".exclude.total",$excludeTotal): 0; setpref(INT,$_Greasify_Custom.".userscript".$xmain.".include.total",$includeTotal); $Qq = 1; #$excIdx>0 ? while ($Qq <= $excludeTotal) &GreasifyGenExcludes:0; $excIdx>0 ? $ctest = "TRUE" : $ctest = "FALSE"; #while ($ctest=="TRUE") &GreasifyGenExcludesK15; $ctest=="TRUE" ? &GreasifyGenExcludesK15 : $ctest = $ctest; $Qq = 1; while ($Qq <= $includeTotal) &GreasifyGenIncludes; $xmain = $xmain + 1; $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); } GreasifyGenExcludes{ &GExcludeAssist1; $excludeURL = gsub(" ", "", $excludeURL); setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".exclude.".$Qq,$excludeURL); $Qq = $Qq + 1; } GreasifyGenExcludesK15{ while ($Qq <= $excludeTotal) &GreasifyGenExcludes; $ctest = "FALSE"; } GreasifyGenIncludes{ &GHostChkSevenAssist1; $includeURL = gsub(" ", "", $includeURL); setpref(STRING,$_Greasify_Custom.".userscript".$xmain.".include.".$Qq,$includeURL); $Qq = $Qq + 1; } GreasifyNewInjectJS{ $P1 = $LOCALPATH."\\".$xname; $CONTENT = readfile( $P1 ); #$USHstart = index($CONTENT, "\/\/ ==UserScript=="); $USHend = index($CONTENT, "\/\/ ==\/UserScript=="); $con2IDX = $USHend + 19; $con2 = substr($CONTENT,$con2IDX); index($con2,"GM_addStyle(")>=1 ? &Greasify_AddStyle:0; &GreasifyInjectJS; } GreasifyNameGenHelp{ $cfs = substr($NS,0,1); while ($cfs == " ") &GreasifyNameGenHelpProc; } GreasifyNameGenHelpProc{ $NS = substr($NS,1); $cfs = substr($NS,0,1); } GreasifyProcessHeader{ $xname = getpref(STRING,$_Greasify_Custom.".userscript".$xmain); $xnameLEN = length($xname); $P1 = $LOCALPATH."\\".$xname; $CONTENT = readfile( $P1 ); $USHstart = index($CONTENT, "\/\/ ==UserScript=="); $USHend = index($CONTENT, "\/\/ ==\/UserScript=="); $con2IDX = $USHend + 19; $activeURL = $URL; $USHend = $USHend - $USHstart; $USHeader = substr($CONTENT, $USHstart, $USHend); $strAidx = index($USHeader, "\/\/\ \@include"); $strA = substr($USHeader,$strAidx); $excIdx = index($USHeader, "\/\/\ \@exclude"); $excIdx>0 ? $excludeURLs = substr($USHeader,$excIdx):0; $excIdx>0 ? $excludeURLs = gsub("\n","",$excludeURLs):0; $excIdx>0 ? $excludeURLs = gsub("\t","",$excludeURLs):0; $NS = index($USHeader, "\/\/\ \@name"); $NS = substr($USHeader,$NS); $NS = substr($NS,10); $NSend = index($NS, "\/\/\ \@namespace"); $NS = substr($NS,0,$NSend); $z = 0; $includeURLs = $strA; $includeURLs = gsub("\n","",$includeURLs); $includeURLs = gsub("\t","",$includeURLs); } GreasifyHelp{ alert("Greasify K-Meleon Userscripts Macro"."\n"."version 0.7.1.9.20071028"."\n\n"."1. You must \'Set Userscripts Directory\' to where you have your UserScripts. (i.e. the directory containuing the .user.js files.) This can be any directory, for instance, create a \"gm\" subdirectory in your K-Meleon dir and copy your scripts there."."\n\n"."2. You must \'Add User Script(s) To Repository\' via the GUI. The scripts contained in your \"gm\" directory will not be active until added into the repository with this step."."\n\n"."3. You can check to see which ones are loaded by selecting \'Show Userscripts In Repository\'."."\n\n"."4. \'Show Actively Applied Scripts To Page\' will verify which userscripts have been applied to the current page."."\n\n"."5. \'NoScript Compatibility Mode\' \- allows the userscript to apply even to pages that are not on the NoScript whitelist (only enable if you are using NoScript"."\n\n"."6. \'Generate Includes and Excludes\' \- should be manually run when upgrading from versions below 0.7. This can also be used to re-generate the include/exclude URL prefs"".\n\n"."Current limits\: 99 maximum scripts\, 8 maximum \@include URLs per script\, 4 maximum \@exclude URLs per script."."\n"."Control\-Alt\-U is keyboard shortcut to toggle Greasify on and off."."\n","Greasify Help",INFO); } ############################## # ----- PRIVATE $_Greasify_Custom=$macroPrefBranch."greasify"; _Greasify_BuildMenu{ $_gmenu="&Greasify"; setmenu(PrivacySecurity,popup,$_gmenu); setmenu($_gmenu,macro,"&Toggle Greasify On/Off",GreasifyToggle,0); #setmenu($_gmenu,separator,"Set Userscripts &Directory"); setmenu($_gmenu,macro,"Set Userscripts &Directory",GreasifySetDir,1); setmenu($_gmenu,separator,"&Add User Script From Repository",2); setmenu($_gmenu,macro,"&Add User Script To Repository",GreasifySetScripts,3); setmenu($_gmenu,macro,"&Remove Script From Repository",GreasifyDelScript,4); setmenu($_gmenu,separator,"&Show Userscripts In Repository",5); setmenu($_gmenu,macro,"&Show Userscripts In Repository",GreasifyScriptsActive,6); setmenu($_gmenu,macro,"Show Actively A&pplied Scripts",GreasifyScriptsApplied,7); #setmenu($_gmenu,separator,"Apply Greasify &Now"); setmenu($_gmenu,separator,"&Advanced",8); #setmenu($_gmenu,separator,"Help",10); setmenu($_gmenu,macro,"Help",GreasifyHelp,10); setmenu($_gmenu,separator,"Apply Greasify &Now",11); setmenu($_gmenu,macro,"Apply Greasify &Now",GreasifyApplyNow,12); &_Greasify_BuildMenuAdv; rebuildmenu($_gmenu); } _Greasify_BuildMenuAdv{ $_advmenu="&Advanced"; setmenu("&Greasify",popup,$_advmenu,9); setmenu($_advmenu,macro,"Toggle NoScript Compatibility Mode",GreasifyNoScriptCompat); setmenu($_advmenu,macro,"Toggle Greasify Statusbar &Message",GreasifySBToggle); setmenu($_advmenu,macro,"Copy Applied Scripts To Clipboard",GreasifyVerifyScript); setmenu($_advmenu,separator,"E&xport Script List to Clipboard"); setmenu($_advmenu,macro,"E&xport Script List to Clipboard",GreasifyExportScriptList); setmenu($_advmenu,macro,"View Script Source In &Browser",GreasifyViewScript); setmenu($_advmenu,separator,"Generate Includes and Excludes"); #setmenu($_advmenu,macro,"Generate Includes and Excludes",GreasifyGenerateIncExcPrefs); #setmenu($_advmenu,macro,"Clear Includes and Excludes",GreasifyClearIncExcPrefs); setmenu($_advmenu,macro,"Generate Includes and Excludes",GreasifyGenerateAllInOne); rebuildmenu($_advmenu); #rebuildmenu($_gmenu); } _Greasify_SetAccels{ setaccel("CTRL ALT U","macros(GreasifyToggle)"); } _GreasifyOnLoad{ #getpref(INT,$_Greasify_Custom.".enabled")!=0 ? &Greasify:0; getpref(BOOL,$_Greasify_Custom.".enablednew")!=false ? &Greasify:0; } $OnInit=$OnInit."_Greasify_SetAccels;_Greasify_BuildMenu;"; #$OnInit=$OnInit."_Greasify_BuildMenu;"; $OnLoad=$OnLoad."_GreasifyOnLoad;"; # ------------------------------------------------------------------------------------------------------------------ $macroModules=$macroModules."Greasify;";