Make use of your favicon with badges, images or videos

Overview

volkswagen status

favico.js

More info here.

Author Miroslav Magda Version 0.3.9

Contributors: Serge Barysiuk, pissflaps, Yaroslav Yakovlev, LoicMahieu, Renan Gonçalves, Adam Savitzky, Jory Graham


License

All code is open source and dual licensed under GPL and MIT. Check the individual licenses for more information.

Change log

0.3.10

  • bugfixes

0.3.9

  • bugfixes

0.3.8

  • bumped version to add it to npm

0.3.7

  • bugfixes & support for font icons (fontawesome)

0.3.6

  • bugfixes

0.3.4

  • new option for position

0.3.3

  • bugfixes

0.3.2

  • support for badge numbers bigger than 999

0.3.1

  • bugfix if <link type="icon"...> is missing

0.3.0

  • font options (font family, font style)
  • badge count more than 9
  • badge positions

0.2.2

  • AMD - CommonJS compatibility

0.2.1

  • Fixed console.log bug
  • registered to bower

0.2.0

  • Webcam support for Opera and Firefox
  • Improved performance for Opera and Firefox
  • New animation type popfade
  • Code cleanup

0.1.1

  • Improving performance in chrome

0.1.0

  • proof of concept

Browser support

  • Chrome: Yes
  • Firefox: Yes
  • Opera: Yes
  • IE: No
  • Edge: No
  • Safari: No (Safari hides favicons)
Comments
  • Allow for dynamic setter function

    Allow for dynamic setter function

    I am interested in using favico.js for slack-for-linux to indicate unseen notifications. It would be used in the tray icon and possibly taskbar icon. Currently favico.js doesn't support this because it can only set against elementId or a <link> it creates.

    To support this functionality, I suggest adding a new option which is a setter callback (i.e. a function that is run every time the image changes). With an integration into node-webkit, it would look like:

    var favicon = new Favico({
      setter: function (png) {
        tray.icon = png;
      }
    });
    
    enhancement 
    opened by twolfson 11
  • Race condition causing a null reference

    Race condition causing a null reference

    I've encountered an error that occurs on line 150:

    TypeError: Cannot read property 'options' of undefined
    

    This seems to happen intermittently, and I have yet to identify reliable repro steps. It seems to happen when performing multiple badge calls in succession. It also seems more likely to happen when the updates occur when the page is invisible.

    My theory as to why this is occurring, and also why it's hard to repro, is that it's a race condition to access the first element of the queue array.

    If _queue.shift(); completes and the resulting queue is empty before line 150 executes, that would throw the error above.

    Here is what I think is happening, although I'm unsure.

    Let's say I have an empty queue, and _lastBadge is false as set in init. Now I call badge(1), which pushes a set of options, which we will call 'A' into the queue and triggers icon.start. This kicks of an animation that lasts, let's say 100ms, using setTimeout to advance the animation at set intervals.

    Now before A is complete, say 10ms in, we kick off another animation by calling badge(2), which we will call 'B'. This is scheduled to complete 110ms into our experiment.

    Now at 100ms, A completes, and the finished callback is called. This function sets _lastBadge to A and shifts A out of the queue, leaving our queue containing 1 element, B.

    The last thing our callback does is call icon.start again, which now triggers the animation.runcall on line 149, using animation A, which is our current value of_lastBadge`. When this is complete, at 200ms, we'll call animation.run again, with the first item in the queue.

    Now fastforward 10ms and our initial B animation completes at 110ms. This also calls finished, which sets _lastBadge to B, shifts B off the queue (we now have an empty queue) and calls icon.start, which does nothing since _queue.length is 0.

    Now fastforward to 200ms in, and the animation that was initiated by the finished callback completes. Instead of calling the finished callback, it calls animation.run with _queue[0].options as the first argument. But wait, _queue is empty!

    Here is a diagram that illustrates what I'm thinking: mmapaf_0

    bug 
    opened by adambom 10
  • Badge fails for 3-digit numbers

    Badge fails for 3-digit numbers

    For any number greater than or equal to 100, the badge displays "00". This screenshot was taken from a badge that was meant to display 921:

    screen shot 2013-10-30 at 10 32 20 am

    enhancement 
    opened by adambom 10
  • Breaks animated favicon

    Breaks animated favicon

    Great script; easy to implement.

    Slight issue, though: when active it breaks animated favicons. Any easy way around this, or plans to change it, or is it unavoidable?

    question 
    opened by ChrisBowyer 8
  • Question/Issue

    Question/Issue

    Is there any way to get this working with a CMS that doesn't use actual directories and pages? Its a DB driven CMS, so a page like test.com/markets is not a physical file or folder anywhere.

    I got it working to where I can push the favicon the first time, but every time after that I get an error saying that the favicon is on a different domain.

    While inspecting the element, I see my normal favicon.ico on the page load. When I click the button to push the new favicon, it then changes to the data: tag. Once it's the data tag I no longer have the ability to change, I only get the different domain error.

    Thanks for any information you can provide on this

    opened by stanggt3 7
  • NS_ERROR_NOT_AVAILABLE

    NS_ERROR_NOT_AVAILABLE

    Hello, I was trying to integrate https://github.com/jsxc/jsxc on my http://simplemachines.org forum (http://poke.lagos.p4u.gr) and I fell in this error. After some digging I traced the error on jsxc.dep.js on lines 32979 or favico.js on line 152 (since jsxc.dep.js is a copy of favico.js adding depedencies only).

    _context.drawImage(_img, 0, 0, _w, _h);
    

    After that I changed the line and it seems to work.

    _img.onload = function(){_context.drawImage(_img, 0, 0, _w, _h);};
    

    I note that I have tested with Firefox and Chromonium (same as Chrome) browser, and Chromonium seems to work fine without the fix, while Firefox doesn't.

    Do you approve of this fix? Do you have anything else to recommend?

    If you approve I will fork the project and make a merge request. Also, I think it is better programming practise to use an EventListener instead.

    opened by souperk 6
  • TypeError: this is undefined

    TypeError: this is undefined

    I'm getting the error TypeError: this is undefined because of the very last block of code in the library:

    // included directly via <script> tag
        else {
            this.Favico = Favico;   // <------ BUG
        }
    

    If this is replaced with window, then it works.

    opened by migig 6
  • the animation state `_running` sometimes stay `false` every time I call it

    the animation state `_running` sometimes stay `false` every time I call it

    I initialized with Favico like this:

    favicon = new Favico
      animation: 'none'
    

    but to find the badge not appearing when I call favicon.badge(3). I debugged into favico.js but found the state __running stay false just like that finished function was never called.

    /**
     * Start animation
     */
    icon.start = function() {
        if (!_ready || _running) { // <-- I found this _running false
            return;
        }
        var finished = function() {
            _lastBadge = _queue[0];
            _running = false;
            console.log('running -> false')
            if (_queue.length > 0) {
                _queue.shift();
                icon.start();
            } else {
    
            }
        };
        if (_queue.length > 0) {
            _running = true;
            console.log('running -> true')
            var run = function() {
                // apply options for this animation
                ['type', 'animation', 'bgColor', 'textColor',
                 'fontFamily', 'fontStyle'].forEach(function(a) {
                    if (a in _queue[0].options) {
                        _opt[a] = _queue[0].options[a];
                    }
                });
                animation.run(_queue[0].options, function() {
                    finished();
                }, false);
            };
            if (_lastBadge) {
                animation.run(_lastBadge.options, function() {
                    run();
                }, true);
            } else {
                run();
            }
        }
    };
    

    But I failed to locate the problem. It happens in Chrome and Firefox but does not happen every time. Looks like when I called it too frequenly and it breaks. Anyone run into this?

    bug 
    opened by tiye 6
  • not working on chrome

    not working on chrome

    it's working fine on firefox, but I don't get it working on chromium or chrome. that's my code and how i link the favicon. is there anything wrong?

    <link rel="shortcut icon" href="http://localhost/oratio/favicon.ico">
    
    window.favicon=new Favico({
        animation:'slide'
    });
    window.favicon.badge(count);
    
    question 
    opened by pichsenmeister 6
  • webcam doesn't work for Chrome on insecure origins.

    webcam doesn't work for Chrome on insecure origins.

    Trying the webcam demo on http://lab.ejci.net/favico.js/ doesn't do anything for Chrome 48.0.2564.82. The button text changes (both buttons), but the icon doesn't change and I'm never asked for permission to use the webcam. Stop webcam seems to refresh the page.

    Console output:

    favicon.min.js:7
    
    getUserMedia() no longer works on insecure origins.
    To use this feature, you should consider switching your application to a secure origin, such as HTTPS.
    See https://goo.gl/rStTGz for more details.
    
    opened by cjwelborn 5
  • This repo is too large for Bower

    This repo is too large for Bower

    It's 4.8M large when I try to install from Bower, that's really large. Considering the bad networking in China it would take some minutes to download. Could you figure out a solution to reduce the size...

    BTW I noted there is samller one here but outdated: https://github.com/fastdivision/favico.js-lite

    enhancement 
    opened by tiye 5
  • Firefox warning: InstallTrigger is deprecated and will be removed in the future

    Firefox warning: InstallTrigger is deprecated and will be removed in the future

    opened by RichardD2 0
  • what if queue lenght is more then 100 ?

    what if queue lenght is more then 100 ?

    I need help to understand why there is a check for if (_queue.length > 100) { throw new Error('Too many badges requests in queue.'); } what if queue lenght is more then 100 ? example chat application user getting more then 100 messges......

    opened by PrakashPaul 0
  • Doesn't work with Chrome 78 (most of the time)

    Doesn't work with Chrome 78 (most of the time)

    The first badge update goes through fine, but then updates are only applied when the user is looking at the page. This seems to be a Chrome change because it works fine in earlier versions of Chrome, but the fix for the time being is to trigger the update twice.

    opened by turt2live 1
  • Firefox 46: Bug on drawing favicon when no link tag is used

    Firefox 46: Bug on drawing favicon when no link tag is used

    Firefox 46 runs into an error when it executes the drawImage line (see below) and no link tag for a favicon is in the html. The reason for that error is that this browser version is not able to draw an empty image on the canvas. Could you please correct that?

    2019-08-19 12_03_22-Dokument1 - Word

    opened by MarcoDeT 0
Owner
Miroslav Magda
https://www.linkedin.com/in/miroslav-magda-bb03aa23/
Miroslav Magda
Extracts favicon of the current page and calculates their murmurhash. Firefox extension source code.

Favicon to Murmurhash Extracts favicon of the current page and calculates their murmurhash. Shows links to shodan search based on favicon murmurhashes

null 16 Dec 17, 2022
App that allows you to control and watch YouTube videos using hand gestures. Additionally, app that allows you to search for videos, playlists, and channels.

YouTube Alternative Interaction App An app I made with Edward Wu that allows you to search and watch videos from YouTube. Leverages Google's YouTube D

Aaron Lam 2 Dec 28, 2021
A Simple yet extendable jQuery modal script built for use with inline HTML, images, videos, and galleries.

jQuery Chaos Modal A Simple yet extendable jQuery modal script built for use with inline HTML, forms, and images in mind. There are many other modal p

Matthew Sigley 3 Oct 8, 2020
Bootstrap5-tags - Replace select[multiple] with nices badges

Tags for Bootstrap 4/5 How to use An ES6 native replacement for select using standards Bootstrap 5 (and 4) styles. No additional CSS needed! Supports

Thomas Portelange 75 Jan 9, 2023
💬 A Twitch (BTTV and FFZ) emotes and badges parser - built with tmi.js in mind

?? A Twitch (BTTV and FFZ) emotes and badges parser - built with tmi.js in mind

Lucas Fernandes 8 Sep 2, 2022
Useful GitHub Badges and based on serverless! 🚀

serverless-github-badges This project is inspired by puf17640/git-badges, but built with the serverless stack: Cloudflare Workers and Cloudflare Worke

Zhou Zhiqiang 38 Dec 20, 2022
This plugin integrates by default with Twitter bootstrap using badges to display the maximum lenght of the field where the user is inserting text. Uses the HTML5 attribute "maxlength" to work.

Bootstrap MaxLength This plugin integrates by default with Twitter bootstrap using badges to display the maximum length of the field where the user is

Maurizio 772 Dec 25, 2022
Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

null 3.5k Dec 30, 2022
Asciifly is a webapp where you can asciify images and youtube videos on the fly.

Asciifly Asciifly is a webapp where you can asciify images and youtube videos on the fly. Come visit at https://asciifly.com Hosting I'm hosting this

André Esser 7 May 23, 2022
A full screen slide show for images and videos

Vanilla JS Slide full screen slide show for videos and images Why? This is a scratch-your-own-itch project as I wanted a way to see images and videos

Christian Heilmann 24 Oct 26, 2022
Automation scripts I use for my Bitburner gameplay videos.

Bitburner Automation Note: I release a new piece of code when I finish a video segment in the series. If it's a multi-part series, the scripts will no

Chris Rabe 68 Dec 25, 2022
Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries.

Image Zoom (jQuery) Plugin Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries that is less th

Mario Duarte 8 Aug 3, 2022
A library for boolean aliases to help you make your code more confusing and make your coworkers hate you.

yup-nope A library for boolean aliases to help you make your code more confusing and make your coworkers hate you. Installation Using npm: npm install

Bence A. Tóth 4 Dec 10, 2022
Compare James Webb Space Telescope images to older images.

How much more powerful is the James Webb Space Telescope when compared to Hubble? Find out! More info Want to help out? CONTRIBUTING.md Blog post with

John Christensen 399 Jan 3, 2023
MidJourney is an AI text-to-image service that generates images based on textual prompts. It is often used to create artistic or imaginative images, and is available on Discord and through a web interface here.

Midjourney MidJourney is an AI text-to-image service that generates images based on textual prompts. It is often used to create artistic or imaginativ

Andrew Tsegaye 8 May 1, 2023
This plugin allows side-by-side notetaking with videos. Annotate your notes with timestamps to directly control the video and remember where each note comes from.

Obsidian Timestamp Notes Use Case Hello Obsidian users! Like all of you, I love using Obsidian for taking notes. My usual workflow is a video in my br

null 74 Jan 2, 2023