Last active
July 13, 2021 13:38
-
-
Save Buntelrus/6914a08285e215fdd9c2530661d9d81c to your computer and use it in GitHub Desktop.
Old Reddit Enhancer (hide comments + time tracking)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Old Reddit Enhancer | |
// @version 0.3.3 | |
// @author Buntelrus | |
// @description hide comments + time tracking | |
// @homepage https://buntel.de | |
// @match https://old.reddit.com/* | |
// @exclude https://old.reddit.com/chat* | |
// @downloadURL https://gist.github.com/Buntelrus/6914a08285e215fdd9c2530661d9d81c/raw/main.bundle.min.user.js | |
// @updateURL https://gist.github.com/Buntelrus/6914a08285e215fdd9c2530661d9d81c/raw/main.bundle.min.user.js | |
// ==/UserScript== | |
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports='<div class="ore-container">\n <div class="changelog scrollbox">\n <span class="close">×</span>\n <h1>Old-Reddit-Enhancer Changelog:</h1>\n <ul>\n <li>\n <h2>Version: 0.3.3</h2>\n <ul>\n <li>change: start counting reddit time at 0 o\'clock (before: last 24h)</li>\n </ul>\n </li>\n <li>\n <h2>Version: 0.3.2</h2>\n <ul>\n <li>fix: config link color</li>\n </ul>\n </li>\n <li>\n <h2>Version: 0.3.1</h2>\n <ul>\n <li>fix: toast message overlaying close button</li>\n <li>make history + changelog scrollable</li>\n <li>fix: trigger time alert correctly if tab becomes dilapidated</li>\n <li>display history in reverse order</li>\n </ul>\n </li>\n <li>\n <h2>Version: 0.3.0-0</h2>\n <ul>\n <li>layout improvements</li>\n <li>show version info in config</li>\n <li>nicer time exhausted notification</li>\n </ul>\n </li>\n <li>\n <h2>Version: 0.2.2</h2>\n <ul>\n <li>fix: only track time if window is active</li>\n </ul>\n </li>\n <li>\n <h2>Version: 0.2.1</h2>\n <ul>\n <li>fix: trigger alert immediately if time is exhausted (before: only on site load)</li>\n <li>added: link in config to open the changelog</li>\n <li>added: option for en/disable time alert <a href="" data-module="1">config</a></li>\n <li>added:\n <a href="" data-module="2">history</a>\n (alt + t)\n </li>\n <li>added: Close open windows with Esc</li>\n </ul>\n </li>\n <li>\n <h2>Version: 0.2</h2>\n <ul>\n <li>Update dependencies</li>\n <li>Introduce Changelog</li>\n <li>Introduce Configuration\n <a href="" data-module="1">open</a>\n (ctrl + alt + t)\n </li>\n <li>Time tracking feature</li>\n </ul>\n </li>\n </ul>\n </div>\n <div class="config">\n <span class="close">×</span>\n <h1>Old-Reddit-Enhancer Config:</h1>\n <span class="version">Installed version: <span id="ore-version"></span></span>\n <form>\n <div>\n <label for="seconds-to-start-new-session">Seconds to start new session</label>\n <input id="seconds-to-start-new-session">\n <div class="unit">sec</div>\n </div>\n <div>\n <label for="daily-reddit-time">Daily Reddit Time</label>\n <input id="daily-reddit-time">\n <div class="unit">min</div>\n </div>\n <div>\n <label for="show-time-alert-time">Seconds how long the time alert is shown</label>\n <input id="show-time-alert-time">\n <div class="unit">sec</div>\n </div>\n <div>\n <label for="show-time-alert">Enable time alert</label>\n <input id="show-time-alert" type="checkbox">\n <div class="unit"></div>\n </div>\n <div>\n <button type="submit">save</button>\n </div>\n </form>\n <nav>\n <a href="" data-module="0">show changelog</a> |\n <a href="" data-module="2">show history</a>\n </nav>\n </div>\n <div class="history scrollbox">\n <span class="close">×</span>\n <h1>History:</h1>\n <ul class="history-list"></ul>\n </div>\n</div>\n<div class="ore-notification-container">\n <div class="toast">\n <div class="toast-header"></div>\n <div class="toast-body"></div>\n </div>\n</div>\n'},function(e,t,n){var o=n(2);"string"==typeof o&&(o=[[e.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(4)(o,r);o.locals&&(e.exports=o.locals)},function(e,t,n){(e.exports=n(3)(!1)).push([e.i,".comment{position:relative;overflow:hidden}.comment .child{border-left:none}.threadline{position:absolute;top:0;height:100%;margin-top:3.4em;padding:4px}.threadline div{height:100%;margin-top:-4px;border-left:1px dotted #727272}.threadline:hover{cursor:pointer}.threadline:hover div{border-left:4px solid #2168c4}.toast{flex-basis:350px;max-width:350px;font-size:.875rem;color:#03071e;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,0.1);box-shadow:0 0.25rem 0.75rem rgba(0,0,0,0.5);opacity:0;border-radius:.25rem}.toast:not(:last-child){margin-bottom:.75rem}.toast.showing{opacity:1}.toast.show{display:block;opacity:1}.toast.hide{display:none}.toast-header{display:flex;align-items:center;padding:.25rem .75rem;color:#03071e;background-color:#fd8668;background-clip:padding-box;border-bottom:1px solid rgba(0,0,0,0.05);border-top-left-radius:calc(.25rem - 1px);border-top-right-radius:calc(.25rem - 1px)}.toast-body{padding:.75rem}.toast{display:none}.ore-container{display:none;position:fixed;z-index:100;top:0;bottom:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,0.4)}.ore-container.show{display:inherit}.ore-container a{color:#253682}.ore-container .close{position:sticky;top:0;color:#080c1d;float:right;font-size:1.3rem;font-weight:bold}.ore-container .close:hover,.ore-container .close:focus{color:#080c1d;text-decoration:none;cursor:pointer}.ore-container>div{display:none;background-color:#92a0e0;margin:2rem auto;padding:1rem;border:1px solid #080c1d;width:80%;color:#080c1d}.ore-container>div.show{display:inherit}.ore-container>div h2{color:#080c1d}.ore-container>div>ul>li{margin-bottom:.5rem}.ore-container>div>ul>li>ul{margin-left:.5rem}.ore-container .config{position:relative}.ore-container .config h1{text-align:center}.ore-container .config .version{position:absolute;bottom:0;right:0;margin:1rem}.ore-container .config form{max-width:600px;margin:auto}.ore-container .config form>div{display:flex;align-items:baseline}.ore-container .config form>div *{flex-basis:100%;margin:.5rem}.ore-container .config form>div label::after{content:':'}.ore-container .config form>div input{flex-shrink:1.5}.ore-container .config form>div .unit{flex-shrink:2}.ore-container .config nav{display:flex;justify-content:center}.ore-container .config nav *{margin:0 .5rem}.ore-container .history .history-list ul>li{display:flex}.ore-container .history .history-list ul>li span{margin-right:1.5rem}.ore-container .scrollbox{max-height:550px;overflow:auto;scrollbar-width:thin;scrollbar-color:#080c1d #92a0e0}.ore-container .scrollbox::-webkit-scrollbar{width:4px}.ore-container .scrollbox::-webkit-scrollbar-thumb{background-color:#080c1d;border-radius:2px}.ore-notification-container{position:fixed;z-index:100;top:0;right:0;padding:1rem}\n",""])},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var r=(s=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(s))))+" */"),i=o.sources.map((function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"}));return[n].concat(i).concat([r]).join("\n")}var s;return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n})).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var o={},r=0;r<this.length;r++){var i=this[r][0];null!=i&&(o[i]=!0)}for(r=0;r<e.length;r++){var s=e[r];null!=s[0]&&o[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){var o,r,i={},s=(o=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===r&&(r=o.apply(this,arguments)),r}),a=function(e,t){return t?t.querySelector(e):document.querySelector(e)},c=function(e){var t={};return function(e,n){if("function"==typeof e)return e();if(void 0===t[e]){var o=a.call(this,e,n);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}t[e]=o}return t[e]}}(),l=null,d=0,u=[],f=n(5);function h(e,t){for(var n=0;n<e.length;n++){var o=e[n],r=i[o.id];if(r){r.refs++;for(var s=0;s<r.parts.length;s++)r.parts[s](o.parts[s]);for(;s<o.parts.length;s++)r.parts.push(y(o.parts[s],t))}else{var a=[];for(s=0;s<o.parts.length;s++)a.push(y(o.parts[s],t));i[o.id]={id:o.id,refs:1,parts:a}}}}function p(e,t){for(var n=[],o={},r=0;r<e.length;r++){var i=e[r],s=t.base?i[0]+t.base:i[0],a={css:i[1],media:i[2],sourceMap:i[3]};o[s]?o[s].parts.push(a):n.push(o[s]={id:s,parts:[a]})}return n}function m(e,t){var n=c(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=u[u.length-1];if("top"===e.insertAt)o?o.nextSibling?n.insertBefore(t,o.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),u.push(t);else if("bottom"===e.insertAt)n.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var r=c(e.insertAt.before,n);n.insertBefore(t,r)}}function v(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=u.indexOf(e);t>=0&&u.splice(t,1)}function g(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var o=function(){0;return n.nc}();o&&(e.attrs.nonce=o)}return b(t,e.attrs),m(e,t),t}function b(e,t){Object.keys(t).forEach((function(n){e.setAttribute(n,t[n])}))}function y(e,t){var n,o,r,i;if(t.transform&&e.css){if(!(i="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=i}if(t.singleton){var s=d++;n=l||(l=g(t)),o=S.bind(null,n,s,!1),r=S.bind(null,n,s,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",b(t,e.attrs),m(e,t),t}(t),o=L.bind(null,n,t),r=function(){v(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(t),o=E.bind(null,n),r=function(){v(n)});return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=s()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return h(n,t),function(e){for(var o=[],r=0;r<n.length;r++){var s=n[r];(a=i[s.id]).refs--,o.push(a)}e&&h(p(e,t),t);for(r=0;r<o.length;r++){var a;if(0===(a=o[r]).refs){for(var c=0;c<a.parts.length;c++)a.parts[c]();delete i[a.id]}}}};var w,x=(w=[],function(e,t){return w[e]=t,w.filter(Boolean).join("\n")});function S(e,t,n,o){var r=n?"":o.css;if(e.styleSheet)e.styleSheet.cssText=x(t,r);else{var i=document.createTextNode(r),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(i,s[t]):e.appendChild(i)}}function E(e,t){var n=t.css,o=t.media;if(o&&e.setAttribute("media",o),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function L(e,t,n){var o=n.css,r=n.sourceMap,i=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||i)&&(o=f(o)),r&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var s=new Blob([o],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(s),a&&URL.revokeObjectURL(a)}},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,o=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(e,t){var r,i=t.trim().replace(/^"(.*)"$/,(function(e,t){return t})).replace(/^'(.*)'$/,(function(e,t){return t}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?e:(r=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:o+i.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")}))}},function(e,t,n){"use strict";n.r(t);n(1);var o=".comment",r=".expand";var i=new class{constructor(){return this.load(),new Proxy(this,{get(e,t,n){const o={secondsToStartNewSession:30,dailyRedditTime:60,showTimeAlert:!0,showTimeAlertTime:10};return Object.keys(o).includes(t.toString())&&!e.hasOwnProperty(t)?o[t]:e[t]}})}load(){const e=JSON.parse(localStorage.getItem("old-reddit-enhancer-config"));for(let t in e)this[t]=e[t]}save(){localStorage.setItem("old-reddit-enhancer-config",JSON.stringify(this))}};let s,a;const c=new WeakMap,l=new WeakMap,d=new WeakMap,u=new WeakMap,f=new WeakMap;let h={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return l.get(e);if("objectStoreNames"===t)return e.objectStoreNames||d.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return v(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function p(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(a||(a=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(g(this),t),v(c.get(this))}:function(...t){return v(e.apply(g(this),t))}:function(t,...n){const o=e.call(g(this),t,...n);return d.set(o,t.sort?t.sort():[t]),v(o)}}function m(e){return"function"==typeof e?p(e):(e instanceof IDBTransaction&&function(e){if(l.has(e))return;const t=new Promise((t,n)=>{const o=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",i),e.removeEventListener("abort",i)},r=()=>{t(),o()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",r),e.addEventListener("error",i),e.addEventListener("abort",i)});l.set(e,t)}(e),t=e,(s||(s=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>t instanceof e)?new Proxy(e,h):e);var t}function v(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const o=()=>{e.removeEventListener("success",r),e.removeEventListener("error",i)},r=()=>{t(v(e.result)),o()},i=()=>{n(e.error),o()};e.addEventListener("success",r),e.addEventListener("error",i)});return t.then(t=>{t instanceof IDBCursor&&c.set(t,e)}).catch(()=>{}),f.set(t,e),t}(e);if(u.has(e))return u.get(e);const t=m(e);return t!==e&&(u.set(e,t),f.set(t,e)),t}const g=e=>f.get(e);const b=["get","getKey","getAll","getAllKeys","count"],y=["put","add","delete","clear"],w=new Map;function x(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(w.get(t))return w.get(t);const n=t.replace(/FromIndex$/,""),o=t!==n,r=y.includes(n);if(!(n in(o?IDBIndex:IDBObjectStore).prototype)||!r&&!b.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,r?"readwrite":"readonly");let s=i.store;o&&(s=s.index(t.shift()));const a=await s[n](...t);return r&&await i.done,a};return w.set(t,i),i}h=(e=>({...e,get:(t,n,o)=>x(t,n)||e.get(t,n,o),has:(t,n)=>!!x(t,n)||e.has(t,n)}))(h);function S(){return function(e,t,{blocked:n,upgrade:o,blocking:r,terminated:i}={}){const s=indexedDB.open(e,t),a=v(s);return o&&s.addEventListener("upgradeneeded",e=>{o(v(s.result),e.oldVersion,e.newVersion,v(s.transaction))}),n&&s.addEventListener("blocked",()=>n()),a.then(e=>{i&&e.addEventListener("close",()=>i()),r&&e.addEventListener("versionchange",()=>r())}).catch(()=>{}),a}("reddit-usage",1,{upgrade(e){if(!e.objectStoreNames.contains("sessions")){const t=e.createObjectStore("sessions",{keyPath:"nr",autoIncrement:!0});t.createIndex("start","start",{unique:!1}),t.createIndex("end","end",{unique:!1})}}})}class E{get currentSessionTime(){return this.idle?0:new Date-this.session.start}get accumulatedDayTime(){return new Promise(e=>{const t=new Date;t.setHours(0,0,0,0),this.db.then(n=>{n.getAllFromIndex("sessions","end",IDBKeyRange.lowerBound(t)).then(n=>{const o=n.reduce((e,o,r)=>{let i;if(this.idle||r!==n.length-1){let e;e=o.start<t?t:o.start,i=o.end.getTime()-e.getTime()}else i=this.currentSessionTime;return e+i},0);e(o)})})})}constructor(e){const t=new Date;this.CONFIG=e,this.db=S(),this.session=E.getSessionFromLocalStorage(),this.idle=!1,this.saveSession(),window.addEventListener("beforeunload",()=>this.saveSessionToLocalStorage()),window.addEventListener("focus",()=>{this.idle=!1,this.track(new Date)}),window.addEventListener("blur",()=>{this.session.end=new Date,this.saveSession(),this.idle=!0}),this.track(t)}static getSessionFromLocalStorage(){const e=JSON.parse(localStorage.getItem("lastRedditSession"));return e&&(e.start=e.start?new Date(e.start):new Date,e.end=e.end?new Date(e.end):new Date),e}static createNewSession(e){return{start:e,end:new Date}}saveSessionToLocalStorage(){this.idle||(this.session.end=new Date),localStorage.setItem("lastRedditSession",JSON.stringify(this.session))}dailyRedditTimeExhausted(){return this.accumulatedDayTime.then(e=>e/1e3/60>this.CONFIG.dailyRedditTime?e:new Promise(t=>{const n=1e3*this.CONFIG.dailyRedditTime*60;setTimeout(()=>{this.dailyRedditTimeExhausted().then(e=>{t(e)})},n-e)}))}track(e){(!this.session||new Date-this.session.end>1e3*this.CONFIG.secondsToStartNewSession)&&(this.session=E.createNewSession(e),this.saveSession())}saveSession(e=this.session){return this.db.then(t=>t.put("sessions",e).then(e=>{this.session.nr=e}))}showHistory(e){const t=e=>{const t=Math.round(e/1e3/60),n=Math.floor(t/60);let o="";return n&&(o+=n.toString()+"h "),`${o}${t%60}min`};e.childNodes.length&&Array.from(e.childNodes).forEach(e=>e.remove()),this.db.then(async n=>{let o=await n.transaction("sessions").store.index("end").openCursor(void 0,"prev"),r={};for(;o;){let e=o.value,t=new Intl.DateTimeFormat("DE-de").format(e.start);r[t]||(r[t]=[]),r[t].push(e),o=await o.continue()}for(let n in r){const o=document.createElement("li"),i=document.createElement("h2"),s=document.createElement("ul");let a=0;r[n].forEach(e=>{const n=document.createElement("li"),o=new Intl.DateTimeFormat("DE-de",{hour:"numeric",minute:"numeric"}),r=e.end-e.start;a+=r;const i=["<span>",o.format(e.start),"Uhr","-",o.format(e.end),"Uhr","</span>","<span>","Duration:",t(r),"</span>"];n.innerHTML=i.join(" "),s.append(n)}),i.innerText=`${n} (${t(a)})`,o.append(i),o.append(s),e.append(o)}})}}var L=n(0),T=n.n(L);function I(e){Array.from(e.querySelectorAll("a[data-module]")).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault();const t=parseInt(e.currentTarget.dataset.module);D[t].show()})})}document.body.insertAdjacentHTML("afterbegin",T.a);const k=document.body.children[0],D=Array.from(document.querySelector(".ore-container").children),j=e=>e.classList.contains("show");D.forEach(e=>{e.show=function(t=!0){t?(e.classList.add("show"),k.classList.contains("show")||k.classList.add("show")):(e.classList.remove("show"),D.some(j)||k.classList.remove("show"))};e.querySelector(".close").addEventListener("click",t=>{e.show(!1)})}),I(k);const O=document.createElement("audio");O.src="https://notificationsounds.com/notification-sounds/clearly-602/download/mp3";const R=document.querySelector(".ore-notification-container > .toast");R.addEventListener("click",()=>R.classList.remove("show")),function(e,t){"0.3.3"!==e.version&&(console.log("update to verion: 0.3.3"),t.show(),e.version="0.3.3",e.save())}(i,D[0]);const A=window.TimeTracker=new E(i);i.showTimeAlert&&A.dailyRedditTimeExhausted().then(e=>{const t=e/1e3/60;!function(e,t){O.play(),R.querySelector(".toast-header").innerText=e;const n=R.querySelector(".toast-body");n.innerHTML=t,I(n),R.classList.add("show"),setTimeout(()=>R.classList.remove("show"),1e3*i.showTimeAlertTime)}("Enough Reddit for today!",`dailyRedditTime: ${i.dailyRedditTime}min, spent: ${Math.round(t)}min<br><a href="" data-module="1">configure</a>`)}),document.addEventListener("keydown",e=>{let t;"KeyT"===e.code&&e.ctrlKey&&e.altKey?t=D[1]:"KeyT"===e.code&&e.altKey?t=D[2]:"Escape"===e.code&&D.forEach(e=>e.show(!1)),t&&(t.classList.contains("show")?t.show(!1):t.show())});const B=document.querySelector(".ore-container form"),C=Array.from(B.querySelectorAll("input")),N=e=>e.split("-").map((e,t)=>0!==t?e.charAt(0).toUpperCase()+e.slice(1):e).join("");C.forEach(e=>{"checkbox"===e.type?e.checked=i[N(e.id)]:e.value=i[N(e.id)]}),B.addEventListener("submit",e=>{e.preventDefault(),C.forEach(e=>{"checkbox"===e.type?i[N(e.id)]=e.checked:i[N(e.id)]=e.value}),i.save(),D[1].show(!1)}),document.getElementById("ore-version").innerText="0.3.3";const M=D[2],U=M.show;M.show=e=>{!1!==e&&A.showHistory(M.querySelector(".history-list")),U(e)};Array.from(document.querySelectorAll(o)).forEach(e=>{const t=document.createElement("div");t.append(document.createElement("div")),t.classList.add("threadline"),t.addEventListener("click",(function(){const e=this.parentElement;e.classList.toggle("collapsed")?(e.classList.remove("noncollapsed"),e.querySelector(r).innerText="[+]"):(e.classList.add("noncollapsed"),e.querySelector(r).innerText="[-]")})),e.append(t)})}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment