1. Create a new funny_title.js file in the \themes\butterfly\source\js directory and add the following code:

     1var OriginTitle = document.title;
     2var titleTime;
     3document.addEventListener('visibilitychange', function () {
     4    if (document.hidden) {
     5        $('[rel="icon"]').attr('href', "/funny.ico");
     6        document.title = '╭(°A°`)╮ Why did you leave ~';
     7        clearTimeout(titleTime);
     8    }
     9    else {
    10        $('[rel="icon"]').attr('href', "/favicon.ico");
    11        document.title = '(ฅ>ω<*ฅ) Welcome back ~' + OriginTitle;
    12        titleTime = setTimeout(function () {
    13            document.title = OriginTitle;
    14        }, 2000);
    15    }
    16});
    
  2. In the theme configuration file _config.butterfly.yml, under the inject section, add the following line in the bottom section to include the js file:

    1- <script src="/js/funny_title.js"></script>