├── .gitignore ├── lobster.otf ├── images ├── nope.gif ├── onfb.png ├── ontw.png ├── favicon.ico ├── icon128.png ├── icon16.png ├── icon32.png ├── icon48.png ├── icon64.png ├── onnope.png ├── onsettings.png └── socialimiter.png ├── manifest.json ├── _locales ├── en │ └── messages.json └── tr │ └── messages.json ├── options.html ├── readme.md ├── main.js ├── options.js └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /lobster.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/lobster.otf -------------------------------------------------------------------------------- /images/nope.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/nope.gif -------------------------------------------------------------------------------- /images/onfb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/onfb.png -------------------------------------------------------------------------------- /images/ontw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/ontw.png -------------------------------------------------------------------------------- /images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/favicon.ico -------------------------------------------------------------------------------- /images/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/icon128.png -------------------------------------------------------------------------------- /images/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/icon16.png -------------------------------------------------------------------------------- /images/icon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/icon32.png -------------------------------------------------------------------------------- /images/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/icon48.png -------------------------------------------------------------------------------- /images/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/icon64.png -------------------------------------------------------------------------------- /images/onnope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/onnope.png -------------------------------------------------------------------------------- /images/onsettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/onsettings.png -------------------------------------------------------------------------------- /images/socialimiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/co3moz/socialimiter/HEAD/images/socialimiter.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Socialimiter", 3 | "description": "Social Limiter, limit the social network. Get freedom", 4 | "version": "1.0", 5 | "manifest_version": 2, 6 | "permissions": [ 7 | "storage", 8 | "http://*/*", 9 | "https://*/*" 10 | ], 11 | "default_locale": "en", 12 | "options_page": "options.html", 13 | "content_scripts": [ 14 | { 15 | "matches": [ 16 | "http://*/*", 17 | "https://*/*" 18 | ], 19 | "js": [ 20 | "main.js" 21 | ], 22 | "css": [ 23 | "style.css" 24 | ] 25 | } 26 | ], 27 | "web_accessible_resources": [ 28 | "images/*" 29 | ], 30 | "icons": { 31 | "16": "images/icon16.png", 32 | "32": "images/icon32.png", 33 | "48": "images/icon48.png", 34 | "64": "images/icon64.png", 35 | "128": "images/icon128.png" 36 | } 37 | } -------------------------------------------------------------------------------- /_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "seconds": { 3 | "message": " seconds " 4 | }, 5 | "minutes": { 6 | "message": " minutes " 7 | }, 8 | "hours": { 9 | "message": " hours " 10 | }, 11 | "days": { 12 | "message": " days " 13 | }, 14 | "months": { 15 | "message": " months " 16 | }, 17 | "left": { 18 | "message": "left" 19 | }, 20 | "nomore": { 21 | "message": "Nope! No more %% today for you :(" 22 | }, 23 | "title": { 24 | "message": "Socialimiter Options" 25 | }, 26 | "allowedTime": { 27 | "message": "Allowed time for a day (second)" 28 | }, 29 | "save": { 30 | "message": "Save Settings" 31 | }, 32 | "resetSites": { 33 | "message": "Reset Everything" 34 | }, 35 | "tooBig": { 36 | "message": "Cannot longer then a day.." 37 | }, 38 | "tooSmall": { 39 | "message": "Cannot shorter then a minute.." 40 | } 41 | } -------------------------------------------------------------------------------- /_locales/tr/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "seconds": { 3 | "message": " saniye " 4 | }, 5 | "minutes": { 6 | "message": " dakika " 7 | }, 8 | "hours": { 9 | "message": " saat " 10 | }, 11 | "days": { 12 | "message": " gün " 13 | }, 14 | "months": { 15 | "message": " ay " 16 | }, 17 | "left": { 18 | "message": "kaldı" 19 | }, 20 | "nomore": { 21 | "message": "Nope! Bugün daha fazla %% yok :(" 22 | }, 23 | "title": { 24 | "message": "Socialimiter Ayarları" 25 | }, 26 | "allowedTime": { 27 | "message": "Günlük izin verilen süre (saniye)" 28 | }, 29 | "save": { 30 | "message": "Ayarları Kaydet" 31 | }, 32 | "resetSites": { 33 | "message": "Her şeyi sıfırla" 34 | }, 35 | "tooBig": { 36 | "message": "Bir günden daha fazla olamaz.." 37 | }, 38 | "tooSmall": { 39 | "message": "Bir dakikadan daha kısa olamaz.." 40 | } 41 | } -------------------------------------------------------------------------------- /options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | __MSG_title__ 5 | 6 | 7 | 8 | 9 | 12 |
13 |

14 | 15 | 16 | 17 |

18 | 19 |

20 | 21 | 22 |

23 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ![img](images/socialimiter.png) 2 | 3 | Chrome extension that limits social network. You allowed some time to use. If you use all your time then, you can't use network anymore. You need to wait 12pm 4 | 5 | You can download it from [chrome web store](https://chrome.google.com/webstore/detail/socialimiter/ooiolpeekfcgicfhjdpnbkfbmnealpbo) 6 | 7 | Features 8 | -------------- 9 | 10 | * **Remaining time** 11 | During the time spent on the site, on left corner you see brand that how much time remaining today for that site. 12 | 13 | * **Sync with google account** 14 | Automaticly sync with all browsers that has your google account. Your remaining time always stored in google servers. 15 | 16 | * **Changeable time** 17 | You can easily change your time spent. If you want to spent only 10 minutes per day, change the allowed time to 10 * 60 => 600 seconds. 18 | > You can't give a number that sorter then 1 minutes and longer then 1 day. 19 | 20 | * **Clear everything** 21 | If you want to reset remaining time, you can do that but please stop using that button :( 22 | 23 | * **Multi-Language Support** 24 | We support English and Turkish. But all code designed to support more. Thanks `chrome.i18n` 25 | 26 | * **No dependency** 27 | Lightweight and no dependency required. 28 | 29 | * **Only works for active tabs** 30 | Counter stops when you jump another tab. If you come back counter starts again. 31 | 32 | * **Seperated times** 33 | Every social site has own time. 34 | 35 | Screenshots 36 | --------------- 37 | 38 | facebook timer running 39 | 40 | ![img1](images/onfb.png) 41 | 42 | ----------- 43 | 44 | twitter timer running 45 | 46 | ![img2](images/ontw.png) 47 | 48 | ----------- 49 | 50 | there is no time to spent, nope screen 51 | 52 | ![img3](images/onnope.png) 53 | 54 | 55 | ---------- 56 | 57 | settings screen 58 | 59 | ![img3](images/onsettings.png) 60 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | !function () { 2 | var check = ["facebook.com", "twitter.com","instagram.com"].find(function (e) { 3 | return new RegExp(e).test(location.hostname); 4 | }); 5 | 6 | if (!check) return; 7 | 8 | var time, t, clock, stopMe, sync; 9 | chrome.storage.sync.get(function (data) { 10 | (data || (data = {})); 11 | (data[check] || (data[check] = {})); 12 | 13 | t = today(); 14 | time = data[check][t] || (data.settings && data.settings.allowedTime)|| 1800; 15 | clock = document.createElement("span"); 16 | clock.className = "socialimiterSpan"; 17 | document.body.appendChild(clock); 18 | 19 | 20 | stopMe = setInterval(everyLittleSecond, 1000); 21 | sync = setInterval(syncData, 2100); 22 | }); 23 | 24 | function everyLittleSecond () { 25 | if (isNaN(time)) { 26 | return location.reload(); 27 | } 28 | 29 | if(document.hidden) return; 30 | 31 | if (--time <= 0) { 32 | createNopeScreen(); 33 | clearInterval(stopMe); 34 | return clearInterval(sync); 35 | } 36 | 37 | clock.style.display = "block"; 38 | clock.innerText = intToTime(time) + chrome.i18n.getMessage("left"); 39 | } 40 | 41 | function syncData () { 42 | if(document.hidden) return; 43 | 44 | chrome.storage.sync.get(function (data) { 45 | (data || (data = {})); 46 | (data[check] || (data[check] = {})); 47 | 48 | data[check][t] = time; 49 | if (!isNaN(time)) { 50 | chrome.storage.sync.set(data); 51 | } 52 | }); 53 | } 54 | 55 | function createNopeScreen () { 56 | document.body.innerHTML = ""; 57 | var span = document.createElement("span"); 58 | var imagespan = document.createElement("span"); 59 | imagespan.className = "socialimiterNope"; 60 | span.className = "socialimiterText"; 61 | span.innerHTML = chrome.i18n.getMessage("nomore").replace("%%", check.replace(/\.com|www\.|\.net|\.org/, "")); 62 | document.body.style.backgroundColor = "#e9eaed"; 63 | document.body.appendChild(imagespan); 64 | document.body.appendChild(span); 65 | } 66 | 67 | 68 | function intToTime (time) { 69 | if (time <= 0) return ""; 70 | if (time < 60) return (time | 0) + chrome.i18n.getMessage("seconds"); 71 | if (time < 3600) return (time / 60 | 0) + chrome.i18n.getMessage("minutes") + intToTime(time % 60); 72 | if (time < 86400) return (time / 3600 | 0) + chrome.i18n.getMessage("hours") + intToTime(time % 3600); 73 | if (time < 2592000) return (time / 86400 | 0) + chrome.i18n.getMessage("days") + intToTime(time % 86400); 74 | return (time / 2592000 | 0) + chrome.i18n.getMessage("months") + intToTime(time % 86400); 75 | } 76 | 77 | function today (x) { 78 | return (x || Date.now()) / (1000 * 60 * 60 * 24) | 0 79 | } 80 | }(); 81 | 82 | -------------------------------------------------------------------------------- /options.js: -------------------------------------------------------------------------------- 1 | function domLoaded () { 2 | var objects = document.getElementsByTagName('html'); 3 | for (var j = 0; j < objects.length; j++) { 4 | var obj = objects[j]; 5 | 6 | var valStrH = obj.innerHTML.toString(); 7 | var valNewH = valStrH.replace(/__MSG_(\w+)__/g, function (match, v1) { 8 | return v1 ? chrome.i18n.getMessage(v1) : ""; 9 | }); 10 | 11 | if (valNewH != valStrH) { 12 | obj.innerHTML = valNewH; 13 | } 14 | } 15 | 16 | chrome.storage.sync.get(function (e) { 17 | (e || (e = {})); 18 | (e.settings || (e.settings = {})); 19 | 20 | var sub = document.getElementById("allowedTimeSub"); 21 | var allowedTime = document.getElementById("allowedTime"); 22 | allowedTime.value = e.settings.allowedTime || 1800; 23 | allowedTime.onchange = allowedTime.onkeyup = function () { 24 | sub.innerText = intToTime(+allowedTime.value); 25 | if (+allowedTime.value > 86400) { 26 | sub.innerText = chrome.i18n.getMessage("tooBig"); 27 | } 28 | 29 | if (+allowedTime.value < 60) { 30 | sub.innerText = chrome.i18n.getMessage("tooSmall"); 31 | } 32 | }; 33 | 34 | allowedTime.onkeyup(); 35 | 36 | var save = document.getElementById("save"); 37 | save.onclick = function (e) { 38 | e.preventDefault(); 39 | 40 | if (+allowedTime.value > 86400) { 41 | return save.style.backgroundColor = "orange"; 42 | } 43 | 44 | if (+allowedTime.value < 60) { 45 | return save.style.backgroundColor = "orange"; 46 | } 47 | 48 | chrome.storage.sync.get(function (e) { 49 | (e || (e = {})); 50 | (e.settings || (e.settings = {})); 51 | 52 | e.settings.allowedTime = +allowedTime.value; 53 | chrome.storage.sync.set(e); 54 | save.style.backgroundColor = "green"; 55 | setTimeout(function() { 56 | save.style.backgroundColor = ""; 57 | }, 1000); 58 | }); 59 | }; 60 | 61 | var resetSites = document.getElementById("resetSites"); 62 | resetSites.onclick = function (e) { 63 | e.preventDefault(); 64 | 65 | chrome.storage.sync.clear(); 66 | save.onclick(e); 67 | resetSites.style.backgroundColor = "green"; 68 | setTimeout(function() { 69 | resetSites.style.backgroundColor = ""; 70 | }, 1000); 71 | }; 72 | 73 | 74 | }); 75 | } 76 | document.addEventListener('DOMContentLoaded', domLoaded); 77 | 78 | function intToTime (time) { 79 | if (time <= 0) return ""; 80 | if (time < 60) return (time | 0) + chrome.i18n.getMessage("seconds"); 81 | if (time < 3600) return (time / 60 | 0) + chrome.i18n.getMessage("minutes") + intToTime(time % 60); 82 | if (time < 86400) return (time / 3600 | 0) + chrome.i18n.getMessage("hours") + intToTime(time % 3600); 83 | if (time < 2592000) return (time / 86400 | 0) + chrome.i18n.getMessage("days") + intToTime(time % 86400); 84 | return (time / 2592000 | 0) + chrome.i18n.getMessage("months") + intToTime(time % 86400); 85 | } 86 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | .socialimiterSpan { 2 | position: fixed; 3 | display: none; 4 | color: white; 5 | top: 9px; 6 | left: 19px; 7 | padding: 5px 35px; 8 | border-radius: 12px; 9 | text-align: center; 10 | z-index: 9999; 11 | opacity: 0.2; 12 | background-color: black; 13 | transition: 0.5s; 14 | cursor: not-allowed; 15 | } 16 | 17 | .socialimiterSpan:hover { 18 | opacity: 0.8; 19 | } 20 | 21 | /*noinspection ALL*/ 22 | .socialimiterNope { 23 | position: fixed; 24 | left: 50%; 25 | top: 50%; 26 | transform: translateX(-50%) translateY(-50%); 27 | background: url('chrome-extension://__MSG_@@extension_id__/images/nope.gif'); 28 | 29 | width: 248px; 30 | height: 200px; 31 | text-align: center; 32 | box-shadow: 0px 0px 153px black; 33 | border-radius: 10px; 34 | transition: 0.5s; 35 | } 36 | 37 | .socialimiterText { 38 | font-size: 20pt; 39 | top: 50%; 40 | left: 50%; 41 | position: fixed; 42 | color: #a20f10;; 43 | transform: translateX(-50%) translateY(-146px); 44 | text-shadow: 1px 1px black; 45 | -webkit-animation-name: blurNormal; 46 | animation-name: blurNormal; 47 | animation-duration: 0.5s; 48 | animation-iteration-count: infinite; 49 | } 50 | 51 | /*noinspection ALL*/ 52 | @keyframes blurNormal { 53 | 0% { 54 | -webkit-filter: blur(2px); 55 | } 56 | 57 | 50% { 58 | -webkit-filter: initial; 59 | } 60 | 61 | 100% { 62 | -webkit-filter: blur(2px); 63 | } 64 | } 65 | 66 | .socialimiterBody { 67 | background: #384047; 68 | font-family: sans-serif; 69 | font-size: 10px; 70 | } 71 | 72 | .socialimiterBody form { 73 | background: #fff; 74 | padding: 4em 4em 2em; 75 | max-width: 400px; 76 | margin: 100px auto 0; 77 | box-shadow: 0 0 1em #222; 78 | border-radius: 5px; 79 | } 80 | 81 | .socialimiterBody p { 82 | margin: 0 0 3em 0; 83 | position: relative; 84 | } 85 | 86 | .socialimiterBody label { 87 | display: block; 88 | font-size: 1.6em; 89 | margin: 0 0 .5em; 90 | color: #333; 91 | } 92 | 93 | .socialimiterBody input { 94 | display: block; 95 | box-sizing: border-box; 96 | width: 100%; 97 | outline: none; 98 | } 99 | 100 | .socialimiterBody input[type="text"], 101 | .socialimiterBody input[type="number"], 102 | .socialimiterBody input[type="password"] { 103 | background: #f5f5f5; 104 | border: 1px solid #e5e5e5; 105 | font-size: 1.6em; 106 | padding: .8em .5em; 107 | border-radius: 5px; 108 | } 109 | 110 | .socialimiterBody input[type="text"]:focus, 111 | .socialimiterBody input[type="number"]:focus, 112 | .socialimiterBody input[type="password"]:focus { 113 | background: #ffffff; 114 | } 115 | 116 | .socialimiterBody input[type="submit"] { 117 | background: #2F558E; 118 | box-shadow: 0 3px 0 0 #1D3C6A; 119 | border-radius: 5px; 120 | border: none; 121 | color: #fff; 122 | cursor: pointer; 123 | display: block; 124 | font-size: 2em; 125 | line-height: 1.6em; 126 | margin: 1em 0 0; 127 | outline: none; 128 | padding: .4em 0; 129 | text-shadow: 0 1px #68B25B; 130 | } 131 | 132 | @font-face { 133 | font-family: Lobster; 134 | src: url("lobster.otf") format("opentype"); 135 | } 136 | 137 | .socialimiterBody .socialimiterLogo { 138 | font-family: Lobster, sans-serif; 139 | font-size: 44pt; 140 | color: white; 141 | text-align: center; 142 | position: fixed; 143 | left: 50%; 144 | z-index: 999; 145 | top: 20px; 146 | transform: translateX(-50%); 147 | } 148 | 149 | .socialimiterBody footer { 150 | text-align: center; 151 | } 152 | 153 | .socialimiterBody footer > a { 154 | color: #DBDBDB; 155 | text-decoration: none; 156 | } 157 | 158 | .socialimiterBody footer > a:hover { 159 | text-decoration: dotted; 160 | } 161 | 162 | .socialimiterBody #allowedTimeSub { 163 | padding-top: 7px; 164 | color: #2F558E; 165 | text-align: right; 166 | } --------------------------------------------------------------------------------