From 8954efb805bf9125f3c51ba7f4bc11a0c3ecf267 Mon Sep 17 00:00:00 2001 From: 12px Date: Tue, 6 Apr 2021 07:09:20 -0600 Subject: [PATCH 1/2] Fix recooring room background. --- turnStyles.sass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/turnStyles.sass b/turnStyles.sass index 9d5d109..a7023d4 100644 --- a/turnStyles.sass +++ b/turnStyles.sass @@ -103,6 +103,9 @@ // turntable styling defaults +#room-view + background: #000000 + .chat .message.stat:not(:hover) opacity: 0.5 From d20a4307a21f4a6f15b55fa8134a171074045ffd Mon Sep 17 00:00:00 2001 From: 12px Date: Tue, 6 Apr 2021 07:10:53 -0600 Subject: [PATCH 2/2] Build v5.3.4 --- build/manifest.json | 2 +- build/turnStyles.css | 3 +++ build/turnStyles.js | 2 +- package.json | 2 +- public/manifest.json | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build/manifest.json b/build/manifest.json index 5e04a8c..8cee32e 100644 --- a/build/manifest.json +++ b/build/manifest.json @@ -1,6 +1,6 @@ { "name": "turnStyles for turntable.fm", - "version": "5.3.3", + "version": "5.3.4", "description": "Apply tweaks to turntable.fm - autobop, autodj, themes, styles, and more!", "manifest_version": 2, "icons": { diff --git a/build/turnStyles.css b/build/turnStyles.css index 89642eb..c5b9e0c 100644 --- a/build/turnStyles.css +++ b/build/turnStyles.css @@ -104,6 +104,9 @@ .ts_toggle input:checked:after { color: gold; } +#room-view { + background: #000000; } + .chat .message.stat:not(:hover) { opacity: 0.5; } diff --git a/build/turnStyles.js b/build/turnStyles.js index b93443a..3a1e2a9 100644 --- a/build/turnStyles.js +++ b/build/turnStyles.js @@ -1 +1 @@ -!function(){var t,e,n=(t=function(t,e){t.exports={version:"5.3.3"}},function(n){return e||t(e={exports:{},parent:n},e.exports),e.exports});const i=t=>`\n
\n

\u2630 tS

\n ${a(t)}\n
\n
\n

\u2715 tS

\n ${l}\n ${d(t)}\n ${h(t)}\n ${c(t)}\n ${r(t)}\n ${u(t)}\n
\n`,s=(t,e,n)=>`\n \n`,o=(t,e)=>`\n \n`,a=t=>`\n ${s(t,"autobop","Autobop")}\n ${s(t,"nextdj","Next DJ Spot")}\n ${s(t,"pingdj","Wait For Ping")}\n`,l='\n
\n
Options
\n
Visual
\n
In Chat
\n
Notify
\n
\n',d=t=>`\n
\n

General Features

\n ${s(t,"autobop","Autobop")}\n ${s(t,"has_vol","Control Volume")}\n
\n ${s(t,"nextdj","Next DJ Spot")}\n ${s(t,"pingdj","Wait For Ping")}\n
\n`,h=t=>`\n
\n

Visual Options

\n ${o(t,"theme")}\n ${o(t,"style")}\n
\n ${s(t,"no_aud","Hide Audience")}\n ${s(t,"no_vid","Hide Player")}\n
\n`,c=t=>`\n
\n

Post Messages In Chat

\n ${s(t,"chat_song","Last Song Stats")}\n ${s(t,"chat_spun","Dropped DJ Stats")}\n
\n ${s(t,"chat_snag","User Snags")}\n ${s(t,"chat_join","User Joins")}\n ${s(t,"chat_left","User Leaves")}\n
\n`,r=t=>`\n
\n

Send Desktop Notifications

\n ${s(t,"ping_pm","On DMs")}\n ${s(t,"ping_chat","On Mentions")}\n ${s(t,"ping_song","On New Songs")}\n
\n`,u=t=>`\n
\n \u2714\ufe0e CLOSE\n v${t.config.version}\n \n \n Join me on the TT Discord\n \n \n
\n`;const g=(t,e,n)=>`${n?`${t}/${n}`:""+t}/${e}.css`,p=(t,e,n)=>{let i=document.createElement("link");i.classList.add("tS-"+(n||"core")),i.type="text/css",i.rel="stylesheet",i.href=g(t,e,n),document.head.append(i)},m=(t,e,n)=>{let i=$("link.tS-"+n);if(!e)return!!i.length&&i.remove();i.length?i.attr("href",g(t,e,n)):p(t,e,n)};const f=()=>{let t=$("#playlist-header .text")[0],e=window.turntable.playlist.fileids.length,n=t.innerHTML.split("")[0];t.innerHTML=`${n} ${e}`};const _=t=>Math.log(t/100)/Math.LN2+4,v=t=>{let e=t||window.util.getSetting("volume");return 100*Math.pow(2,e-4)},b=`\n
\n \n \n \n Muted For One Song\n
\n`;const w=()=>{$(window).focus();let t={bubbles:!0,cancelable:!0,view:window},e=document.querySelectorAll(".awesome-button")[0],n=new MouseEvent("click",t);return!e.dispatchEvent(n)};const y=(t,e,n="")=>`\n
\n \n ${t}\n ${e}\n \n
\n`;const j={};(t=>{t.Log=t=>console.info("turnStyles :: "+t),t.user=()=>window.turntable.user,t.view=()=>window.turntable.topViewController,t.icon=()=>this.__base+"/images/icon128.png",t.userName=e=>{let n=t.view().userMap[e];return n?n.attributes.name:"Someone"},t.buddyName=t=>{let e=window.turntable.buddyList.pmWindows[t];return!!e&&e.otherUser.attributes.name},t.pinged=e=>{let n="@"+t.user().attributes.name.toLowerCase();return e.toLowerCase().indexOf(n)>-1},t.toggleClass=(t,e)=>{let n=$("body").hasClass(t);e&&!n&&$("body").addClass(t),n&&!e&&$("body").removeClass(t)},t.holding={},t.suspend=function(t,e,n){this.holding[n]?clearTimeout(this.holding[n]):t&&t();let i=1e3*e;this.holding[n]=setTimeout((()=>{delete this.holding[n]}).bind(this),i)}})(j),(t=>{t.on=function(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e.bind(this))},t.emit=function(t,e,n){let i=this.events[t];if(i)for(let s of i)s(e,n)},t.handle=function(t){t.command&&this.emit(t.command,t)},t.events={}})(j),(t=>{t.default={theme:"dark",style:"",autobop:!0,nextdj:!1,pingdj:!1,has_vol:!1,no_aud:!1,no_vid:!1,ping_pm:!1,ping_song:!1,ping_chat:!1,chat_song:!1,chat_spun:!1,chat_snag:!1,chat_join:!1,chat_left:!1},t.options={theme:{dark:"Dark Mode",night:"Night Mode",cosmic:"Cosmic",midnight:"Midnight"},style:{pink:"Pink",blue:"Blue",teal:"Teal",green:"Green",purple:"Purple"}},t.saveConfig=function(t){let e="checkbox"==t.target.type,n=t.target.id.split("ts_").join(""),i=e?t.target.checked:t.target.value;$(`#ts_hotbar #${t.target.id}, #ts_window #${t.target.id}`).prop(e?"checked":"value",i),this.config[n]=i;let s=JSON.stringify(this.config);window.localStorage.setItem("tsdb",s),this.Log("saved config");let o="style"==n||"theme"==n;this.lobby?o&&this.updateThemes(n,i):this.emit("update",n,i)}})(j),(t=>{t.last_played={},t.now_playing={},t.current_djs={},t.buildCache=function(t){for(let e of t.djids)this.cacheNewDJ(e);this.cacheTrack(t.currentSong)},t.cacheTrack=function(t){let e=t&&t.room?t.room.metadata.current_song:t,n=t&&t.upvoters?t.upvoters.length:0,i=!!e&&e.djid,s={...this.now_playing},o={love:n,hate:0,snag:0,dj:i};this.last_played=s,this.now_playing=e?{...e.metadata,...o}:{},s.song&&this.current_djs[s.dj]?(this.current_djs[s.dj].spun+=1,this.current_djs[s.dj].love+=s.love,this.current_djs[s.dj].hate+=s.hate,this.current_djs[s.dj].snag+=s.snag):s.song&&this.cacheNewDJ(s.dj,s);let a=!1;s.song&&(a=`${s.love}\u2764\ufe0f${s.hate}\ud83d\udc94${s.snag}\ud83d\udc96`),this.emit("tracked",a),this.Log("cached track: "+(this.now_playing.song||"nosong"))},t.cacheNewDJ=function(t,e){let n=t.user?t.user[0].userid:t;this.current_djs[n]||(this.current_djs[n]={spun:e&&e.spun?e.spun:0,love:e&&e.love?e.love:0,hate:e&&e.hate?e.hate:0,snag:e&&e.snag?e.snag:0}),this.Log("cached new DJ: "+n)},t.cacheSnags=function(){this.now_playing.snag+=1},t.cacheVotes=function(t){this.now_playing.love=t.room.metadata.upvotes,this.now_playing.hate=t.room.metadata.downvotes},t.clearOldDJ=function(t){let e=t.user[0].name,n=t.user[0].userid;if(!this.current_djs[n])return;let i={...this.current_djs[n]},s=`${i.love}\u2764\ufe0f${i.hate}\ud83d\udc94${i.snag}\ud83d\udc96${i.spun}\u25b6\ufe0f`;delete this.current_djs[n],this.emit("dropped",e,s)},t.on("attach",t.buildCache),t.on("add_dj",t.cacheNewDJ),t.on("rem_dj",t.clearOldDJ),t.on("nosong",t.cacheTrack),t.on("newsong",t.cacheTrack),t.on("snagged",t.cacheSnags),t.on("update_votes",t.cacheVotes)})(j),(t=>{t.init=function(){if(this.__base)return;this.chrome=!!window.tsBase,this.__base=window.tsBase||"https://ts.pixelcrisis.co/build";let t=window.localStorage.getItem("tsdb"),e=t?JSON.parse(t):{},i=n({}).version;this.config={...this.default,...e,version:i},this.emit("loaded",this.config),this.attach()},t.attach=function(){let n=window.turntable;if(!n)return this.Log("no room");if(this.lobby=$("#turntable #topBG").length,this.lobby)return this.buildWindow();let i=()=>setTimeout(t.attach.bind(this),150);if(!n.user)return i();let s=e(n,"roomId");return s&&e(s,"roomData")?(this.realVolume=window.turntablePlayer.realVolume,n.addEventListener("message",this.handle.bind(this)),this.emit("attach",s),void this.Log("loaded room")):i()};const e=function(t,e){for(let n in t){let i=t[n];if(null!=i&&i[e])return i}}})(j),(t=>{t.buildWindow=function(){$(".header-bar").append(i(this)),$(".ts_menu").on("click",()=>{$("#ts_hotbar, #ts_window").toggleClass("active")}),$("#ts_tabs div").on("click",t=>{$("#ts_tabs div, .ts_tab").removeClass("active"),$("."+t.currentTarget.className).addClass("active")}),$(".ts_option").on("change",t.saveConfig.bind(this))},t.on("attach",t.buildWindow)})(j),(t=>{t.loadThemes=function(t){p(this.__base,"turnStyles"),this.updateThemes("theme",t.theme),this.updateThemes("style",t.style)},t.updateThemes=function(t,e){"theme"==t&&m(this.__base,e,"themes"),"style"==t&&m(this.__base,e,"styles")},t.on("loaded",t.loadThemes),t.on("update",t.updateThemes)})(j),(t=>{t.modify=function(){$("#songs-wrapper").on("DOMSubtreeModified","#songs",f),f(),this.toggleClass("ts_hide_videos",this.config.no_vid),this.toggleClass("ts_hide_audience",this.config.no_aud),$("#upload-button").after('
'),$("#ts_upload").on("click",()=>{let t=window.turntable.playlist;t.isFiltering&&t.clearSearchBar(),$("#queue-header").removeClass("normal").addClass("edit"),t.queue.batchEditMode()})},t.hidden=function(t,e){"no_vid"==t&&this.toggleClass("ts_hide_videos",e),"no_aud"==t&&this.toggleClass("ts_hide_audience",e)},t.on("attach",t.modify),t.on("update",t.hidden)})(j),(t=>{t.loadVolume=function(){let t=this.config.has_vol,e=$("body").hasClass("has-volume");this.toggleClass("has-volume",t),e&&!t&&this.remVolume(),t&&!e&&this.addVolume()},t.addVolume=function(){$(".header-content").append(b),$("#ts_mute").on("click",this.toggleMute.bind(this)),$("#ts_slider").on("input",this.saveVolume.bind(this)),$("#ts_slider").on("DOMMouseScroll mousewheel",this.onVolWheel.bind(this))},t.remVolume=function(){$("#ts_volume").remove(),window.turntablePlayer.realVolume=this.realVolume},t.saveVolume=function(t){let e=(t=t.target?t.target.value:t)>0?_(t):-3;window.turntablePlayer.realVolume=e>6?this.realVolume:v,window.turntablePlayer.setVolume(e),window.util.setSetting("volume",e)},t.onVolWheel=function(t){const e=e();let n=t.originalEvent.shiftKey?1:5,i=t.originalEvent.deltaY>0?e-n:e+n;return i=i<0?0:i>100?100:i,$("#ts_slider")[0].value=i,this.saveVolume(i),!1},t.checkMuted=function(){this.mute&&this.toggleMute()},t.toggleMute=function(){this.mute=!this.mute,$("#ts_volume").toggleClass("muted",this.mute);let t=this.mute?-3:_(v());window.turntablePlayer.setVolume(t),this.Log("turned mute "+(this.mute?"on":"off"))},t.on("attach",t.loadVolume),t.on("update",t.loadVolume),t.on("nosong",t.checkMuted),t.on("newsong",t.checkMuted)})(j),(t=>{t.autoBop=function(){if(this.bopping&&clearTimeout(this.bopping),!this.config.autobop)return;let t=7*Math.random()*100;this.bopping=setTimeout(w,t)},t.on("attach",t.autoBop),t.on("newsong",t.autoBop)})(j),(t=>{t.checkDecks=function(){this.config.nextdj&&(this.config.pingdj?this.suspend(null,2,"nextdj"):this.tryJumping())},t.tryJumping=function(){if(!$(".become-dj").length)return this.Log("nextdj: no spot");this.Log("nextdj: taking spot"),this.view().becomeDj()},t.isSpinning=function(t){if(!this.config.nextdj)return;if(this.user().id!=t.user[0].userid)return;this.config.nextdj=!1,$("#ts_hotbar #ts_nextdj").prop("checked",!1),$("#ts_hotbar #ts_nextdj").trigger("change");let e="You've Hopped On Deck!",n="NextDJ is now disabled.";this.sendNotify({head:e,text:n}),this.postToChat(e,n)},t.nextOnPing=function(t){this.pinged(t.text)&&this.holding.nextdj&&this.tryJumping()},t.on("attach",t.checkDecks),t.on("update",t.checkDecks),t.on("rem_dj",t.checkDecks),t.on("add_dj",t.isSpinning),t.on("speak",t.nextOnPing)})(j),(t=>{t.notifyAuth=function(){let t=this.config;return!(!(t.ping_chat||t.ping_pm||t.ping_song)||this.chrome||!("Notification"in window)||"denied"===Notification.permission||"default"===Notification.permission&&(this.Log("requesting notifcation permission"),Notification.requestPermission(),1))},t.stopNotify=function(){return!!document.hasFocus()||!this.chrome&&!this.notifyAuth()},t.sendNotify=function(t,e){if(this.stopNotify())return;let n=this.notifyType(t);return e?this.suspend(n,5,e):n()},t.notifyType=function(t){let e={type:"tsNotify",notification:t},n={icon:this.icon(),body:t.text};return this.chrome?()=>window.postMessage(e):()=>{let e=new Notification(t.head,n);e.onclick=()=>{window.focus(),e.close()}}},t.postToChat=function(t,e,n){$(".chat .messages").append(y(t,e,n)),this.view().updateChatScroll()},t.on("attach",t.notifyAuth),t.on("update",t.notifyAuth)})(j),(t=>{t.alertSong=function(t){let e=this.now_playing.song;if(e&&this.config.ping_song){let n="Now Playing: "+e,i=t||"By: "+this.now_playing.artist;this.sendNotify({head:n,text:i})}if(t&&this.config.chat_song){let e=this.last_played,n=`${e.song} by ${e.artist}`;this.postToChat(t,n,"stat")}},t.alertDrop=function(t,e){if(this.config.chat_spun){let n=`${t} - ${e}`,i="- is done spining!";this.postToChat(n,i,"stat")}},t.alertPm=function(t){if(this.config.ping_pm){let e=this.buddyName(t.senderid),n=e?"New PM from: "+e:"New PM";this.sendNotify({head:n,text:t.text},"ping_pm")}},t.alertPing=function(t){if(this.pinged(t.text)&&this.config.ping_chat){let e=`[${this.view().roomData.name}] @${t.name}`;this.sendNotify({head:e,text:t.text},"ping_chat")}},t.alertSnag=function(t){if(this.config.chat_snag){let e=this.userName(t.userid),n="has snagged this track!";this.postToChat(e,n,"snag")}},t.alertJoin=function(t){if(this.config.chat_join){let e=t.user[0].name;this.postToChat(e,"joined.","join")}},t.alertLeft=function(t){if(this.config.chat_left){let e=t.user[0].name;this.postToChat(e,"left.","left")}},t.on("pmmed",t.alertPm),t.on("speak",t.alertPing),t.on("snagged",t.alertSnag),t.on("tracked",t.alertSong),t.on("dropped",t.alertDrop),t.on("registered",t.alertJoin),t.on("deregistered",t.alertLeft)})(j),window.$tS=j,window.$tS.init()}(); \ No newline at end of file +!function(){var t,e,n=(t=function(t,e){t.exports={version:"5.3.4"}},function(n){return e||t(e={exports:{},parent:n},e.exports),e.exports});const i=t=>`\n
\n

\u2630 tS

\n ${a(t)}\n
\n
\n

\u2715 tS

\n ${l}\n ${d(t)}\n ${h(t)}\n ${c(t)}\n ${r(t)}\n ${u(t)}\n
\n`,s=(t,e,n)=>`\n \n`,o=(t,e)=>`\n \n`,a=t=>`\n ${s(t,"autobop","Autobop")}\n ${s(t,"nextdj","Next DJ Spot")}\n ${s(t,"pingdj","Wait For Ping")}\n`,l='\n
\n
Options
\n
Visual
\n
In Chat
\n
Notify
\n
\n',d=t=>`\n
\n

General Features

\n ${s(t,"autobop","Autobop")}\n ${s(t,"has_vol","Control Volume")}\n
\n ${s(t,"nextdj","Next DJ Spot")}\n ${s(t,"pingdj","Wait For Ping")}\n
\n`,h=t=>`\n
\n

Visual Options

\n ${o(t,"theme")}\n ${o(t,"style")}\n
\n ${s(t,"no_aud","Hide Audience")}\n ${s(t,"no_vid","Hide Player")}\n
\n`,c=t=>`\n
\n

Post Messages In Chat

\n ${s(t,"chat_song","Last Song Stats")}\n ${s(t,"chat_spun","Dropped DJ Stats")}\n
\n ${s(t,"chat_snag","User Snags")}\n ${s(t,"chat_join","User Joins")}\n ${s(t,"chat_left","User Leaves")}\n
\n`,r=t=>`\n
\n

Send Desktop Notifications

\n ${s(t,"ping_pm","On DMs")}\n ${s(t,"ping_chat","On Mentions")}\n ${s(t,"ping_song","On New Songs")}\n
\n`,u=t=>`\n
\n \u2714\ufe0e CLOSE\n v${t.config.version}\n \n \n Join me on the TT Discord\n \n \n
\n`;const g=(t,e,n)=>`${n?`${t}/${n}`:""+t}/${e}.css`,p=(t,e,n)=>{let i=document.createElement("link");i.classList.add("tS-"+(n||"core")),i.type="text/css",i.rel="stylesheet",i.href=g(t,e,n),document.head.append(i)},m=(t,e,n)=>{let i=$("link.tS-"+n);if(!e)return!!i.length&&i.remove();i.length?i.attr("href",g(t,e,n)):p(t,e,n)};const f=()=>{let t=$("#playlist-header .text")[0],e=window.turntable.playlist.fileids.length,n=t.innerHTML.split("")[0];t.innerHTML=`${n} ${e}`};const _=t=>Math.log(t/100)/Math.LN2+4,v=t=>{let e=t||window.util.getSetting("volume");return 100*Math.pow(2,e-4)},b=`\n
\n \n \n \n Muted For One Song\n
\n`;const w=()=>{$(window).focus();let t={bubbles:!0,cancelable:!0,view:window},e=document.querySelectorAll(".awesome-button")[0],n=new MouseEvent("click",t);return!e.dispatchEvent(n)};const y=(t,e,n="")=>`\n
\n \n ${t}\n ${e}\n \n
\n`;const j={};(t=>{t.Log=t=>console.info("turnStyles :: "+t),t.user=()=>window.turntable.user,t.view=()=>window.turntable.topViewController,t.icon=()=>this.__base+"/images/icon128.png",t.userName=e=>{let n=t.view().userMap[e];return n?n.attributes.name:"Someone"},t.buddyName=t=>{let e=window.turntable.buddyList.pmWindows[t];return!!e&&e.otherUser.attributes.name},t.pinged=e=>{let n="@"+t.user().attributes.name.toLowerCase();return e.toLowerCase().indexOf(n)>-1},t.toggleClass=(t,e)=>{let n=$("body").hasClass(t);e&&!n&&$("body").addClass(t),n&&!e&&$("body").removeClass(t)},t.holding={},t.suspend=function(t,e,n){this.holding[n]?clearTimeout(this.holding[n]):t&&t();let i=1e3*e;this.holding[n]=setTimeout((()=>{delete this.holding[n]}).bind(this),i)}})(j),(t=>{t.on=function(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e.bind(this))},t.emit=function(t,e,n){let i=this.events[t];if(i)for(let s of i)s(e,n)},t.handle=function(t){t.command&&this.emit(t.command,t)},t.events={}})(j),(t=>{t.default={theme:"dark",style:"",autobop:!0,nextdj:!1,pingdj:!1,has_vol:!1,no_aud:!1,no_vid:!1,ping_pm:!1,ping_song:!1,ping_chat:!1,chat_song:!1,chat_spun:!1,chat_snag:!1,chat_join:!1,chat_left:!1},t.options={theme:{dark:"Dark Mode",night:"Night Mode",cosmic:"Cosmic",midnight:"Midnight"},style:{pink:"Pink",blue:"Blue",teal:"Teal",green:"Green",purple:"Purple"}},t.saveConfig=function(t){let e="checkbox"==t.target.type,n=t.target.id.split("ts_").join(""),i=e?t.target.checked:t.target.value;$(`#ts_hotbar #${t.target.id}, #ts_window #${t.target.id}`).prop(e?"checked":"value",i),this.config[n]=i;let s=JSON.stringify(this.config);window.localStorage.setItem("tsdb",s),this.Log("saved config");let o="style"==n||"theme"==n;this.lobby?o&&this.updateThemes(n,i):this.emit("update",n,i)}})(j),(t=>{t.last_played={},t.now_playing={},t.current_djs={},t.buildCache=function(t){for(let e of t.djids)this.cacheNewDJ(e);this.cacheTrack(t.currentSong)},t.cacheTrack=function(t){let e=t&&t.room?t.room.metadata.current_song:t,n=t&&t.upvoters?t.upvoters.length:0,i=!!e&&e.djid,s={...this.now_playing},o={love:n,hate:0,snag:0,dj:i};this.last_played=s,this.now_playing=e?{...e.metadata,...o}:{},s.song&&this.current_djs[s.dj]?(this.current_djs[s.dj].spun+=1,this.current_djs[s.dj].love+=s.love,this.current_djs[s.dj].hate+=s.hate,this.current_djs[s.dj].snag+=s.snag):s.song&&this.cacheNewDJ(s.dj,s);let a=!1;s.song&&(a=`${s.love}\u2764\ufe0f${s.hate}\ud83d\udc94${s.snag}\ud83d\udc96`),this.emit("tracked",a),this.Log("cached track: "+(this.now_playing.song||"nosong"))},t.cacheNewDJ=function(t,e){let n=t.user?t.user[0].userid:t;this.current_djs[n]||(this.current_djs[n]={spun:e&&e.spun?e.spun:0,love:e&&e.love?e.love:0,hate:e&&e.hate?e.hate:0,snag:e&&e.snag?e.snag:0}),this.Log("cached new DJ: "+n)},t.cacheSnags=function(){this.now_playing.snag+=1},t.cacheVotes=function(t){this.now_playing.love=t.room.metadata.upvotes,this.now_playing.hate=t.room.metadata.downvotes},t.clearOldDJ=function(t){let e=t.user[0].name,n=t.user[0].userid;if(!this.current_djs[n])return;let i={...this.current_djs[n]},s=`${i.love}\u2764\ufe0f${i.hate}\ud83d\udc94${i.snag}\ud83d\udc96${i.spun}\u25b6\ufe0f`;delete this.current_djs[n],this.emit("dropped",e,s)},t.on("attach",t.buildCache),t.on("add_dj",t.cacheNewDJ),t.on("rem_dj",t.clearOldDJ),t.on("nosong",t.cacheTrack),t.on("newsong",t.cacheTrack),t.on("snagged",t.cacheSnags),t.on("update_votes",t.cacheVotes)})(j),(t=>{t.init=function(){if(this.__base)return;this.chrome=!!window.tsBase,this.__base=window.tsBase||"https://ts.pixelcrisis.co/build";let t=window.localStorage.getItem("tsdb"),e=t?JSON.parse(t):{},i=n({}).version;this.config={...this.default,...e,version:i},this.emit("loaded",this.config),this.attach()},t.attach=function(){let n=window.turntable;if(!n)return this.Log("no room");if(this.lobby=$("#turntable #topBG").length,this.lobby)return this.buildWindow();let i=()=>setTimeout(t.attach.bind(this),150);if(!n.user)return i();let s=e(n,"roomId");return s&&e(s,"roomData")?(this.realVolume=window.turntablePlayer.realVolume,n.addEventListener("message",this.handle.bind(this)),this.emit("attach",s),void this.Log("loaded room")):i()};const e=function(t,e){for(let n in t){let i=t[n];if(null!=i&&i[e])return i}}})(j),(t=>{t.buildWindow=function(){$(".header-bar").append(i(this)),$(".ts_menu").on("click",()=>{$("#ts_hotbar, #ts_window").toggleClass("active")}),$("#ts_tabs div").on("click",t=>{$("#ts_tabs div, .ts_tab").removeClass("active"),$("."+t.currentTarget.className).addClass("active")}),$(".ts_option").on("change",t.saveConfig.bind(this))},t.on("attach",t.buildWindow)})(j),(t=>{t.loadThemes=function(t){p(this.__base,"turnStyles"),this.updateThemes("theme",t.theme),this.updateThemes("style",t.style)},t.updateThemes=function(t,e){"theme"==t&&m(this.__base,e,"themes"),"style"==t&&m(this.__base,e,"styles")},t.on("loaded",t.loadThemes),t.on("update",t.updateThemes)})(j),(t=>{t.modify=function(){$("#songs-wrapper").on("DOMSubtreeModified","#songs",f),f(),this.toggleClass("ts_hide_videos",this.config.no_vid),this.toggleClass("ts_hide_audience",this.config.no_aud),$("#upload-button").after('
'),$("#ts_upload").on("click",()=>{let t=window.turntable.playlist;t.isFiltering&&t.clearSearchBar(),$("#queue-header").removeClass("normal").addClass("edit"),t.queue.batchEditMode()})},t.hidden=function(t,e){"no_vid"==t&&this.toggleClass("ts_hide_videos",e),"no_aud"==t&&this.toggleClass("ts_hide_audience",e)},t.on("attach",t.modify),t.on("update",t.hidden)})(j),(t=>{t.loadVolume=function(){let t=this.config.has_vol,e=$("body").hasClass("has-volume");this.toggleClass("has-volume",t),e&&!t&&this.remVolume(),t&&!e&&this.addVolume()},t.addVolume=function(){$(".header-content").append(b),$("#ts_mute").on("click",this.toggleMute.bind(this)),$("#ts_slider").on("input",this.saveVolume.bind(this)),$("#ts_slider").on("DOMMouseScroll mousewheel",this.onVolWheel.bind(this))},t.remVolume=function(){$("#ts_volume").remove(),window.turntablePlayer.realVolume=this.realVolume},t.saveVolume=function(t){let e=(t=t.target?t.target.value:t)>0?_(t):-3;window.turntablePlayer.realVolume=e>6?this.realVolume:v,window.turntablePlayer.setVolume(e),window.util.setSetting("volume",e)},t.onVolWheel=function(t){const e=e();let n=t.originalEvent.shiftKey?1:5,i=t.originalEvent.deltaY>0?e-n:e+n;return i=i<0?0:i>100?100:i,$("#ts_slider")[0].value=i,this.saveVolume(i),!1},t.checkMuted=function(){this.mute&&this.toggleMute()},t.toggleMute=function(){this.mute=!this.mute,$("#ts_volume").toggleClass("muted",this.mute);let t=this.mute?-3:_(v());window.turntablePlayer.setVolume(t),this.Log("turned mute "+(this.mute?"on":"off"))},t.on("attach",t.loadVolume),t.on("update",t.loadVolume),t.on("nosong",t.checkMuted),t.on("newsong",t.checkMuted)})(j),(t=>{t.autoBop=function(){if(this.bopping&&clearTimeout(this.bopping),!this.config.autobop)return;let t=7*Math.random()*100;this.bopping=setTimeout(w,t)},t.on("attach",t.autoBop),t.on("newsong",t.autoBop)})(j),(t=>{t.checkDecks=function(){this.config.nextdj&&(this.config.pingdj?this.suspend(null,2,"nextdj"):this.tryJumping())},t.tryJumping=function(){if(!$(".become-dj").length)return this.Log("nextdj: no spot");this.Log("nextdj: taking spot"),this.view().becomeDj()},t.isSpinning=function(t){if(!this.config.nextdj)return;if(this.user().id!=t.user[0].userid)return;this.config.nextdj=!1,$("#ts_hotbar #ts_nextdj").prop("checked",!1),$("#ts_hotbar #ts_nextdj").trigger("change");let e="You've Hopped On Deck!",n="NextDJ is now disabled.";this.sendNotify({head:e,text:n}),this.postToChat(e,n)},t.nextOnPing=function(t){this.pinged(t.text)&&this.holding.nextdj&&this.tryJumping()},t.on("attach",t.checkDecks),t.on("update",t.checkDecks),t.on("rem_dj",t.checkDecks),t.on("add_dj",t.isSpinning),t.on("speak",t.nextOnPing)})(j),(t=>{t.notifyAuth=function(){let t=this.config;return!(!(t.ping_chat||t.ping_pm||t.ping_song)||this.chrome||!("Notification"in window)||"denied"===Notification.permission||"default"===Notification.permission&&(this.Log("requesting notifcation permission"),Notification.requestPermission(),1))},t.stopNotify=function(){return!!document.hasFocus()||!this.chrome&&!this.notifyAuth()},t.sendNotify=function(t,e){if(this.stopNotify())return;let n=this.notifyType(t);return e?this.suspend(n,5,e):n()},t.notifyType=function(t){let e={type:"tsNotify",notification:t},n={icon:this.icon(),body:t.text};return this.chrome?()=>window.postMessage(e):()=>{let e=new Notification(t.head,n);e.onclick=()=>{window.focus(),e.close()}}},t.postToChat=function(t,e,n){$(".chat .messages").append(y(t,e,n)),this.view().updateChatScroll()},t.on("attach",t.notifyAuth),t.on("update",t.notifyAuth)})(j),(t=>{t.alertSong=function(t){let e=this.now_playing.song;if(e&&this.config.ping_song){let n="Now Playing: "+e,i=t||"By: "+this.now_playing.artist;this.sendNotify({head:n,text:i})}if(t&&this.config.chat_song){let e=this.last_played,n=`${e.song} by ${e.artist}`;this.postToChat(t,n,"stat")}},t.alertDrop=function(t,e){if(this.config.chat_spun){let n=`${t} - ${e}`,i="- is done spining!";this.postToChat(n,i,"stat")}},t.alertPm=function(t){if(this.config.ping_pm){let e=this.buddyName(t.senderid),n=e?"New PM from: "+e:"New PM";this.sendNotify({head:n,text:t.text},"ping_pm")}},t.alertPing=function(t){if(this.pinged(t.text)&&this.config.ping_chat){let e=`[${this.view().roomData.name}] @${t.name}`;this.sendNotify({head:e,text:t.text},"ping_chat")}},t.alertSnag=function(t){if(this.config.chat_snag){let e=this.userName(t.userid),n="has snagged this track!";this.postToChat(e,n,"snag")}},t.alertJoin=function(t){if(this.config.chat_join){let e=t.user[0].name;this.postToChat(e,"joined.","join")}},t.alertLeft=function(t){if(this.config.chat_left){let e=t.user[0].name;this.postToChat(e,"left.","left")}},t.on("pmmed",t.alertPm),t.on("speak",t.alertPing),t.on("snagged",t.alertSnag),t.on("tracked",t.alertSong),t.on("dropped",t.alertDrop),t.on("registered",t.alertJoin),t.on("deregistered",t.alertLeft)})(j),window.$tS=j,window.$tS.init()}(); \ No newline at end of file diff --git a/package.json b/package.json index 5a3e436..af3ccb5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "turnStyles", - "version": "5.3.3", + "version": "5.3.4", "main": "turnStyles.js", "repository": "git@github.com:pixelcrisis/turntable-tweaks.git", "author": "pixelcrisis ", diff --git a/public/manifest.json b/public/manifest.json index 5e04a8c..8cee32e 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,6 +1,6 @@ { "name": "turnStyles for turntable.fm", - "version": "5.3.3", + "version": "5.3.4", "description": "Apply tweaks to turntable.fm - autobop, autodj, themes, styles, and more!", "manifest_version": 2, "icons": {