K-Meleon

KMeleonWiki > Resources > MacroLibrary > MacroLibrary2 > Image Browsing Toolbar

Submitted by: Johnny Sim-Bravenboer



Notes:

A toolbar to make image browsing just a little easier.


The Zoom macros and the Open Image Links macro are already part of K-Meleon 0.9


To complete the toolbar, rename and convert (or recreate) this picture to imagebrowsing.bmp and place it in the folder of the skin in use:


internal://b923b9982b8463a0f6965f8e2e7b127c.jpeg


If you do not wish to use the imagebrowsing.bmp toolbar picture, just leave out the references to the picture in the toolbar macro.


Changes:

04-30-05 Replaced the popup message with a statusbar message for Auto Image Resize macro
04-07-05 Added the Slideshow Generator macro
04-03-05 Added the Auto Image Resize macro

References:



To use this macro, please make the following additions to your .cfg files:

In Macros:

# Image Browsing Macros

hide_visited_links{
    $macro="hide-visited-links"; &JSEnable;
}
hide-visited-links{
    open("javascript:(function(){var newSS, styles=':visited {display: none}'; if(document.createStyleSheet) { document.createStyleSheet("javascript:'"+styles+"'"); } else { newSS=document.createElement('link'); newSS.rel='stylesheet'; newSS.href='data:text/css,'+escape(styles); document.documentElement.childNodes[0].appendChild(newSS); } })();");
}


increment_link{
    $macro="increment-link"; &JSEnable;
}
increment-link{
    open("javascript:(function(){ var e,s; IB=1; function isDigit(c) { return ("0" <= c && c <= "9") } L = location.href; LL = L.length; for (e=LL-1; e>=0; --e) if (isDigit(L.charAt(e))) { for(s=e-1; s>=0; --s) if (!isDigit(L.charAt(s))) break; break; } ++s; if (e<0) return; oldNum = L.substring(s,e+1); newNum = "" + (parseInt(oldNum,10) + IB); while (newNum.length < oldNum.length) newNum = "0" + newNum; location.href = L.substring(0,s) + newNum + L.slice(e+1); })();");
}


decrement_link{
    $macro="decrement-link"; &JSEnable;
}
decrement-link{
    open("javascript:(function(){ var e,s; IB=-1; function isDigit(c) { return ("0" <= c && c <= "9") } L = location.href; LL = L.length; for (e=LL-1; e>=0; --e) if (isDigit(L.charAt(e))) { for(s=e-1; s>=0; --s) if (!isDigit(L.charAt(s))) break; break; } ++s; if (e<0) return; oldNum = L.substring(s,e+1); newNum = "" + (parseInt(oldNum,10) + IB); while (newNum.length < oldNum.length) newNum = "0" + newNum; location.href = L.substring(0,s) + newNum + L.slice(e+1); })();");
}


go_refferer{
    $macro="go-refferer"; &JSEnable;
}
go-refferer{
    open("javascript:if(!document.referrer) alert("No referrer!"); else document.location = document.referrer; void 0");
}

# Enable Automatic Image Resize

toggle_autoresize{    
   menu = "Enable Auto Image Resizing"
   togglepref(BOOL, "browser.enable_automatic_image_resizing");
   &Sync;
   getpref(BOOL, "browser.enable_automatic_image_resizing") == true ? $warn = "ENABLED" :$warn = "DISABLED";
   statusbar("Auto Image Resize has been ".$warn."!.");
}

# List Image Links

list_images_links{
menu=&List Images As Links
open("javascript:{var images='';for (var idx=0;idx<document.images.length;idx++)images+='<a href=\'+document.images[idx].src+\'>'+document.images[idx].src+'</a>
\';images='<html><body>'+images+'</body></html>\';document.write(images);document.close();}"); } # Open all links in a page OpenAllLinks{ getpref(BOOL, $popups) == "true" ? &PB2 : &AllLinks; } PB2{ &PBToggle; &AllLinks; &PBToggle; } AllLinks{ $macro = "OpenAll"; &JSEnable; } OpenAll{ open("javascript:(function(){var n_to_open,dl,dll,i; function linkIsSafe(u) { if (u.substr(0,7)=='mailto:') return false; if (u.substr(0,11)=='javascript:') return false; return true; } n_to_open = 0; dl = document.links; dll = dl.length; for(i = 0; i < dll; ++i) { if (linkIsSafe(dl[i].href)) ++n_to_open; } if (!n_to_open) alert ('no links'); else { if (confirm('Open ' + n_to_open + ' links in new windows?')) for (i = 0; i < dll; ++i) if (linkIsSafe(dl[i].href)) window.open(dl[i].href); } })();"); } # Open Selected Links open_selected_links{ getpref(BOOL, $popups) == "true" ? &PB3 : &selected_links; } PB3{ &PBToggle; &selected_links; &PBToggle; } selected_links{ $macro = "selected-links"; &JSEnable; } selected-links{ open("javascript:(function(){var n_to_open,dl,dll,i; function linkIsSafe(u) { if (u.substr(0,7)=='mailto:') return false; if (u.substr(0,11)=='javascript:') return false; return true; } n_to_open = 0; dl = document.links; dll = dl.length; if (window.getSelection && window.getSelection().containsNode) { /* mozilla */ for(i=0; i<dll; ++i) { if (window.getSelection().containsNode(dl[i], true) && linkIsSafe(dl[i].href)) ++n_to_open; } if (n_to_open && confirm('Open ' + n_to_open + ' selected links in new windows?')) { for(i=0; i<dll; ++i) if (window.getSelection().containsNode(dl[i], true) && linkIsSafe(dl[i].href)) window.open(dl[i].href); } } /* /mozilla */ if (!n_to_open) { /*ie, or mozilla with no links selected: this section matches open_all_links, except for the alert text */ for(i = 0; i < dll; ++i) { if (linkIsSafe(dl[i].href)) ++n_to_open; } if (!n_to_open) alert ('no links'); else { if (confirm('No links selected. Open ' + n_to_open + ' links in new windows?')) for (i = 0; i < dll; ++i) if (linkIsSafe(dl[i].href)) window.open(dl[i].href); } } })();"); } # Slideshow slide_show{ $macro = "slideshow"; &JSEnable; } # Slideshow Generator slideshow{ pluginmsg(toolbars,"CheckButton","Image Browsing Bar,macros(slide_show),".1); open("javascript:(function(){var intv=prompt('Enter number of seconds between images. (Click Back to stop the show)');if(intv&&!isNaN(intv)){with(document){write('<html><frameset rows=\"*,22\" framespacing=0 border=0 frameborder=no><frame noresize frameborder=no><frame scrolling=no noresize frameborder=no></frameset></html>');frames[0].location.href=document.location.href;var docstr='<html><body bgcolor=#33FF99 style=\"margin-top:0px\">\n';docstr+='<span id=\"caption\"></span></body>\n';docstr+='<script>\nvar reloadIntv='+intv+';\nvar secsLeft='+intv+';\nfunction reloadFrame(){secsLeft=reloadIntv+1;Increment();}\nfunction countDown(){secsLeft--;showTime();}\nfunction showTime(){document.getElementById(\"caption\").innerHTML=\"-- Current image: \"+L.substring(0,s)+newNum+L.slice(e+1) +\" -- Next image in \"+ parseInt(secsLeft)+\" secs.\";}\nfunction Increment(){IB=1;\nfunction isDigit(c){return ("0"<= c && c <= "9");}L = parent.frames[0].location.href;LL = L.length;for (e=LL-1; e>=0; --e)if (isDigit(L.charAt(e))){for(s=e-1; s>=0; --s)if (!isDigit(L.charAt(s)))break;break;}++s;if (e<0)return;oldNum = L.substring(s,e+1);newNum = "" + (parseInt(oldNum,10) + IB);while (newNum.length < oldNum.length)newNum = "0" + newNum;parent.frames[0].location.href = L.substring(0,s) + newNum + L.slice(e+1);}\nsetInterval(\"reloadFrame()\",'+intv*1000+');\nsetInterval(\"countDown()\",1000);\nshowTime();\n</script>\n</html>';frames[1].document.write(docstr);}}})();"); }

Sync{
     &EngineSync;
     setcheck("macros(SN0)",getpref(INT,$so)==0? true:false);
     setcheck("macros(SN1)",getpref(INT,$so)==1? true:false);
     setcheck("macros(SN2)",getpref(INT,$so)==2? true:false);
     setcheck("macros(SearchLock)",getpref(BOOL,$sl));
     ...
     pluginmsg(toolbars,"CheckButton","Image Browsing Bar,macros(toggle_autoresize),".(getpref(BOOL,"browser.enable_automatic_image_resizing")? 1:0));
     pluginmsg(toolbars,"CheckButton","Image Browsing Bar,macros(slide_show),".0);
}


In Toolbars:

# Image Browsing Toolbar

%ifplugin macros

Image Browsing Bar(66,10){

    Zoom In {
    macros(ZoomInImages)
    Zoom In Images
    imagebrowsing.bmp[0]
    }
    
    Zoom Out {
    macros(ZoomOutImages)
    Zoom Out Images    
    imagebrowsing.bmp[1]
    }
    
    Open Links {
    macros(open_image_links)
    Open Linked Images
    imagebrowsing.bmp[2]
    }
    
    Hide Visited {
    macros(hide_visited_links)
    Hide Visited Links
    imagebrowsing.bmp[3]
    }
    
    ++ Link {
    macros(increment_link)
    Increment Last Number Of Link
    imagebrowsing.bmp[4]
    }
    
    -- Link {
    macros(decrement_link)
    Decrement Last Number Of Link
    imagebrowsing.bmp[5]
    }   

    List Links {
    macros(list_images_links)
    Create an Image Link List
    imagebrowsing.bmp[6]
    }
    
    All Links {
    macros(OpenAllLinks, Open All Links)
    Open All Links
    imagebrowsing.bmp[7]
    }
    
    Selected {
    macros(open_selected_links)
    Open Selected Links
    imagebrowsing.bmp[8]
    }
    
    Go Refferer {
    macros(go_refferer)
    Go to Refferer

    imagebrowsing.bmp[9]
    }
    
    BugMeNot {
    macros(BugMeNot, Bypass Registration (BugMeNot))
    Bypass Site Registration
    imagebrowsing.bmp[10]
    }
    
    Auto Resize {
    macros(toggle_autoresize)
    En- or Disable Auto Image Resize
    imagebrowsing.bmp[11]
    }
    
    Slide Show {
    macros(slide_show)
    Automatically Increment Image Numbering
    imagebrowsing.bmp[12]
    }
}

%endif


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.