[
  {
    "path": "README.md",
    "content": "\n感觉工作之后写代码经常忘记喝水，而且我本身因为以前经常不吃早饭，有点胆结石，医生也提醒说要多喝水多运动，但是写代码集中精神之后就经常忘记了。。\n\n前段时间公司体检后发现颈椎有点前倾，明明才刚毕业几个月，，大家一起注意身体健康吧！下面是插件的详细内容～\n\n**干杯！妈妈再也不担心我不喝水了!**\n\nv0.08更新！2019-9-7 13.04\n\n修复浏览器console报错的小bug🙇‍\n\nv0.07更新！11-9 19.40\n\n修复了小鸭子倒着游的重大bug🙇‍\n\nv0.06更新！10-19 15.00\n\n之前计时重复了，30分钟喝一杯了，我对不起大家！小鸭子替我道歉🙇\n\nv0.05更新！10-18 19:55\n\n1.白天点击refresh小鸭子变大，晚上点击小鸭子会变小（否则小鸭子似乎经常遭到毒手变的太大回不去！\n\n2.提示出来之后点击喝水按钮后就刷新计时，不需要在标签里点击刷新啦！\n\n3.谢谢大家的支持！\n\n*年轻人的第一个chrome插件！*\n*关注大家的身体健康;*\n*rua!!!*\n\n**主要功能：**\n\n①通过标签提醒距离上次喝水已经过了多久\n\n②点击右上角刷新时间\n\n③点击太阳切换白昼/黑夜暂停时间\n\n④60分钟会提示并且标签会变色\n\n（其实这个是一个养成类的游戏，小鸭子喝水会变大，不及时喝水会变小。哈哈哈哈哈哈\n(感谢小朋友🐏医生)\n\nThe first chrome plugin for young people!\nTeach young people write plugins at the same time;\nPay attention to your health;\nRua!!!\n\nThe main function:\n①Through the badge to remind you how long it has been since drinking the last time\n②click the top right corner to refresh the countdown\n③click the sun to switch to the day/night to pause time losing\n④every 60 minutes will prompt at once and the label will change color\n\n(In fact, this is a game , the ducklings will get bigger when you drink water and refresh, and they will get smaller if they don’t drink in time. Hahahahahaha\n(Thanks to doctors 🐏 - the one I love!❤)\n\n![day](http://p0.meituan.net/dpgroup/e6c968d702f336e8d2df47f4adf7ec0639097.png)\n\n![night](http://p1.meituan.net/dpgroup/a95fc0ee6e4ec1cc62a3b21e2271e6eb42003.png)\n\nchrome插件地址：https://chrome.google.com/webstore/search/%E5%B9%B2%E6%9D%AF?hl=zh-CN\n\ngithub地址:https://github.com/sologgfun/drinkNow\n"
  },
  {
    "path": "background.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n    <title>background</title>\n</head>\n\n<body>\n\n</body>\n<script src=\"./js/background.js\"></script>\n\n</html>"
  },
  {
    "path": "js/background.js",
    "content": "var count = 0;\nvar winWidth = 1440;\nvar winHeight = 860;\nvar notificationId;\nvar countdownId = 0;\nvar light = true;\nvar duckwidth = 15;\n\nchrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {\n    winWidth = request.winWidth;\n    winHeight = request.winHeight;\n    sendResponse('');\n});\n\nfunction duckbecomeslim() {\n    duckwidth = duckwidth - 4;\n}\n\nfunction duckbecomefat() {\n    duckwidth = duckwidth + 2;\n}\n\nfunction smallduck() {\n    duckwidth = duckwidth - 2;\n}\n\nfunction getduckwidth() {\n    return duckwidth;\n}\n\nfunction checklight() {\n    return light\n}\n\nfunction turnlight() {\n    light = !light;\n}\n//计时器，在后台默默计时\nfunction timer() {\n    //黑夜停止计时\n    if (!light) {\n        return count / 36\n    }\n    if (count < 3600) {\n        count++;\n        //给浏览器右上角图标加上计时badge\n        chrome.browserAction.setBadgeText({\n            text: Math.floor(count / 60) + ''\n        });\n        chrome.browserAction.setBadgeBackgroundColor({\n            color: \"#70d2c9\"\n        });\n    }\n    //60分钟通知喝水！\n    if (count == 3600) {\n        duckbecomeslim();\n        notificationAction();\n        count++;\n    }\n    if (count >= 3600) {\n        //图标改成红色和sos文案！\n        chrome.browserAction.setBadgeText({\n            text: 'sos'\n        });\n        chrome.browserAction.setBadgeBackgroundColor({\n            color: [255, 0, 0, 255]\n        });\n    }\n    return count / 36\n}\n\nfunction refresh() {\n    count = 0;\n    //清除五分钟倒计时\n    window.clearInterval(countdownId);\n}\n\nvar fivemin = 0;\nvar Countdown = function () {\n    fivemin++;\n    if (fivemin == 300) {\n        notificationAction();\n        fivemin = 0;\n    }\n};\n\nfunction notificationAction() {\n    //notification的id要清空，否则create的时候之前id没有清空则会失效\n    chrome.notifications.clear(\"1\",\n        (id) => {\n\n        });\n    chrome.notifications.create(\"1\", {\n        type: 'basic',\n        iconUrl: 'img/logo.png',\n        title: '快喝水！',\n        buttons: [{\n            title: \"喝水\",\n            iconUrl: 'img/yellowsmile.png'\n        }, {\n            title: \"等会儿\",\n            iconUrl: 'img/redsmile.png'\n        }],\n        message: '已经一个小时没喝水了！小鸭子渴死了！'\n    });\n}\n\nchrome.notifications.onButtonClicked.addListener(function (id, btnIndex) {\n    count = btnIndex ? count : 0;\n});\n\nfunction getWandH() {\n    var WandH = {\n        winWidth: winWidth,\n        winHeight: winHeight\n    }\n    return WandH\n}\n\nsetInterval(timer, 1000);"
  },
  {
    "path": "js/content-script.js",
    "content": "var winWidth, winHeight;\n\n//屏幕分辨率版本\nwinWidth = window.screen.width;\nwinHeight = window.screen.height;\n\nchrome.runtime.sendMessage({\n\twinWidth: winWidth,\n\twinHeight: winHeight\n}, function (response) {\n});"
  },
  {
    "path": "js/popup.js",
    "content": "var bg = chrome.extension.getBackgroundPage();\nvar getHtml = document.getElementsByTagName(\"html\")[0];\nvar getClock = document.getElementById(\"img\");\nvar getImg = document.getElementById(\"clock\");\nvar progressbar = document.getElementById(\"progressbar\");\nvar light = bg.checklight();\nvar check = document.getElementById(\"toggle\");\nvar duckwidth = bg.getduckwidth();\n//true为黑夜\ngetClock.style.width = duckwidth + \"%\";\n\nif (!light) {\n    getImg.innerText = `大魔法让时间停止了!`;\n    check.checked = true;\n    getHtml.id = \"htmlbg2\";\n    progressbar.id = \"progressbar2\";\n}\n//自适应窗口大小\nvar WandH = bg.getWandH();\ngetHtml.style.width = WandH.winWidth * 1 / 5 + \"px\";\ngetHtml.style.height = WandH.winHeight * 1 / 7 + \"px\";\nconsole.log(getHtml.style.width);\n\n//文字提示和小鸭子前进\ngetClock.style.left = `${bg.timer() - 10}%`;\n\nif (Math.floor(bg.timer() * 36 / 60) == 60) {\n    getImg.innerText = `快给我水给我水给我水！`;\n    getClock.src = \"../img/dead.png\";\n}\n\n//水向前变色\ndocument.getElementsByClassName(\"bar\")[0].style.width = `${bg.timer()}%`;\n\ndocument.getElementById(\"refresh\").addEventListener(\"click\", function (e) {\n    //刷新计数，小鸭子跑回去\n    bg.refresh();\n    if (!light) {\n        getClock.style.width = duckwidth - 2 + \"%\";\n        bg.smallduck();\n        duckwidth = duckwidth - 2;\n    } else {\n        getClock.style.width = duckwidth + 2 + \"%\";\n        bg.duckbecomefat();\n        duckwidth = duckwidth + 2;\n    }\n    getClock.src = \"../img/imok.png\";\n    getImg.innerText = `哧溜哧溜～喝水了！`;\n    getClock.style.left = `-10%`;\n    document.getElementsByClassName(\"bar\")[0].style.width = `0%`;\n});\n//点击太阳时改变样式，并且让background.js中的计数暂停\ndocument.getElementById(\"sun\").addEventListener(\"click\", function (e) {\n    //暂停计数\n    bg.turnlight();\n    light = !light;\n    //样式改变\n    if (bg.checklight()) {\n        getImg.innerText = ``;\n        check.checked = false;\n        getHtml.id = \"htmlbg\";\n        progressbar.id = \"progressbar\";\n    } else {\n        getImg.innerText = `大魔法让时间停止了！`;\n        check.checked = true;\n        getHtml.id = \"htmlbg2\";\n        progressbar.id = \"progressbar2\";\n    }\n});"
  },
  {
    "path": "manifest.json",
    "content": "{\n    \"manifest_version\": 2,\n    \"name\": \"干杯！cheers~!\",\n    \"version\": \"0.0.8\",\n    \"description\": \"干杯！妈妈再也不担心我不喝水了!cheers!Mom is no longer worried that I will not drink water!\",\n    \"icons\": {\n        \"16\": \"./img/logo.png\",\n        \"48\": \"./img/logo.png\",\n        \"128\": \"./img/logo.png\"\n    },\n    \"permissions\": [\n        \"notifications\",\n        \"webRequestBlocking\",\n        \"storage\"\n    ],\n    \"background\": {\n        \"page\": \"./background.html\"\n    },\n    \"browser_action\": {\n        \"default_icon\": \"./img/logo.png\",\n        \"default_title\": \"drinkNow!\",\n        \"default_popup\": \"./popup.html\"\n    },\n    \"content_scripts\": [\n        {\n            \"matches\": [\n                \"<all_urls>\"\n            ],\n            \"js\": [\n                \"js/content-script.js\"\n            ],\n            \"run_at\": \"document_start\"\n        }\n    ]\n}"
  },
  {
    "path": "popup.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\" id=\"htmlbg\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n    <title>drinknow</title>\n</head>\n\n<body>\n    <input id=\"toggle\" class=\"switch\" type=\"checkbox\">\n    <div id=\"wrapper\">\n        <div class=\"toplayer\">\n            <div id=\"sun\" class=\"sun\"></div>\n            <div id=\"clock\" class=\"clock\"></div>\n            <img src=\"./img/refresh.png\" alt=\"imok\" id=\"refresh\">\n        </div>\n        <div class=\"imgWrap\">\n            <img src=\"./img/imok.png\" alt=\"imok\" id=\"img\">\n            <div class=\"progressbar\" id=\"progressbar\">\n                <span class=\"bar\"></span>\n            </div>\n        </div>\n    </div>\n</body>\n\n<style scoped>\n    *,\n    :after,\n    :before {\n        box-sizing: border-box;\n    }\n\n    #htmlbg {\n        width: 400px;\n        height: 150px;\n        margin: 0;\n        background-color: #fffce6c7;\n    }\n\n    #htmlbg2 {\n        width: 400px;\n        height: 150px;\n        margin: 0;\n        background-color: #333e7d;\n    }\n\n    .switch {\n        display: none;\n    }\n\n    body {\n        margin: 0;\n        width: 100%;\n        height: 100%;\n        position: relative;\n        /* background-color: rgb(54, 106, 211); */\n    }\n\n    #wrapper {\n        display: flex;\n        flex-direction: column;\n        justify-content: space-around;\n        margin-left: 5%;\n        width: 90%;\n        height: 100%;\n        margin-top: 1%;\n        /* background-color: rgb(54, 106, 211); */\n    }\n\n    .progressbar {\n        height: 80%;\n        position: relative;\n        left: -10%;\n        width: 120%;\n        background-color: #a4cfe8;\n        border-radius: 20px;\n        transition: all .4s ease-in-out 0s;\n    }\n\n    .bar {\n        display: block;\n        width: 0%;\n        height: 100%;\n        background-color: rgb(54, 106, 211);\n        border-radius: 20px;\n        transition: width 1s linear, background-color .4s ease-in-out 0s;\n    }\n\n\n    #img {\n        width: 15%;\n        position: relative;\n        animation: duck 0.5s linear infinite alternate;\n        transition: left 1s linear;\n    }\n\n    .toplayer {\n        width: 100%;\n        height: 20%;\n        display: flex;\n        justify-content: space-between;\n        align-items: center;\n    }\n\n    .clock {\n        position: relative;\n        left: -15%;\n    }\n\n    .imgWrap {\n        width: 100%;\n        height: 20%;\n    }\n\n    .sun {\n        width: 50px;\n        height: 50px;\n        background-color: #ff3f2b;\n        border-radius: 50%;\n        cursor: pointer;\n        transition: all .4s ease-in-out 0s;\n    }\n\n    #refresh {\n        position: absolute;\n        top: 1%;\n        right: 2%;\n        width: 8%;\n        cursor: pointer;\n    }\n\n    @keyframes duck {\n        from {\n            transform: rotate(-10deg);\n        }\n\n        to {\n            transform: rotate(10deg);\n        }\n    }\n\n    #progressbar:before {\n        z-index: -2;\n        border: 60px solid transparent;\n        border-bottom: 100px solid rgba(0, 0, 0, .25);\n        border-left-width: 75px;\n        border-right-width: 65px;\n\n        width: 0;\n        height: 0;\n        bottom: 0;\n        transition: all .4s ease-in-out 0s;\n\n        content: '';\n        position: absolute;\n    }\n\n    #progressbar:after {\n        z-index: -2;\n        right: 0;\n        border: 60px solid transparent;\n        border-bottom: 140px solid rgba(0, 0, 0, .35);\n        border-left-width: 100px;\n        border-right-width: 100px;\n\n        width: 0;\n        height: 0;\n        bottom: 0;\n        transition: all .4s ease-in-out 0s;\n\n        content: '';\n        position: absolute;\n    }\n\n    #progressbar2:before {\n        z-index: -2;\n        left: 50%;\n        border: 60px solid transparent;\n        border-bottom: 100px solid rgba(255, 255, 255, .15);\n        border-left-width: 75px;\n        border-right-width: 65px;\n        width: 0;\n        height: 0;\n        bottom: 0;\n        transition: all .4s ease-in-out 0s;\n        content: '';\n        position: absolute;\n    }\n\n    #progressbar2:after {\n        z-index: -2;\n        right: 30%;\n        border: 60px solid transparent;\n        border-bottom: 140px solid rgba(255, 255, 255, .2);\n        border-left-width: 100px;\n        border-right-width: 100px;\n\n        width: 0;\n        height: 0;\n        bottom: 0;\n        transition: all .4s ease-in-out 0s;\n\n        content: '';\n        position: absolute;\n    }\n\n    #toggle:checked+#wrapper .sun {\n        transform: scale(0.8);\n        background-color: #fff;\n        transition: all .4s ease-in-out 0s;\n    }\n\n    #toggle:checked+#wrapper .clock {\n        color: #fff\n    }\n\n    #toggle:checked+#wrapper .bar {\n        background-color: rgb(53, 79, 132);\n    }\n\n    #toggle:checked+#wrapper .progressbar {\n        background-color: #99c0d6;\n    }\n</style>\n<script src=\"js/popup.js\"></script>\n\n</html>"
  }
]