Skip to content

Commit

Permalink
Build v11.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelcrisis committed May 1, 2022
1 parent 3388a09 commit dffb029
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 104 deletions.
48 changes: 25 additions & 23 deletions build/inject.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
// turnStyles preloading and injection

// what kind of browser are we in
const target = chrome || browser
const syncDB = target.storage ? target.storage.sync : false
const script = target.runtime.getURL("turnStyles.js")

const stored = window.localStorage.getItem("tsdb")
const remove = window.localStorage.getItem("ts-reset")
const bridge = target.storage ? target.storage.sync : false

const Attach = () => {
if (remove) return Format()
if (bridge) return Backup()
if (syncDB) return Backup()
else return Inject()
}

const Format = () => {
// wipe out all tS data
window.localStorage.removeItem("tsdb")
window.localStorage.removeItem("ts-reset")
if (bridge) bridge.remove([ "tsdb" ], () => Backup())
if (syncDB) syncDB.remove([ "tsdb" ], () => Backup())
else Inject()
}

const Backup = () => {
// save to bridge (addon db)
// save to syncDB (addon db)
let save = stored && !remove
let tsdb = save ? JSON.parse(stored) : false
if (tsdb) bridge.set({ tsdb })
if (tsdb) syncDB.set({ tsdb })
// listen for db update messages
window.addEventListener("message", Update)
// fetch and inject our app data
bridge.get([ "tsdb" ], db => Inject(db))
syncDB.get([ "tsdb" ], db => Inject(db))
}

const Update = ev => {
let tsdb = ev.data.tsdb
if (tsdb) bridge.set({ tsdb: tsdb })
const Update = Event => {
let tsdb = Event.data.tsdb
if (tsdb) syncDB.set({ tsdb: tsdb })
}

const Inject = db => {
const Inject = DB => {
// inject tS data and scripts
let backup = db ? JSON.stringify(db.tsdb || {}) : false
let script = target.runtime.getURL("turnStyles.js")
let extURL = script.split("/turnStyles.js")[0]
let tsSync = DB ? DB.tsdb : {}
let tsBase = script.split("/turnStyles.js")[0]
// inject the base URL/sync data
window.localStorage.setItem("tsBase", extURL)
window.localStorage.setItem("tsSync", backup)
if (tsSync) tsSync = JSON.stringify(tsSync)
window.localStorage.setItem("tsBase", tsBase)
window.localStorage.setItem("tsSync", tsSync)
// the main script gets us started
Append(script)
}

const Append = js => {
// append JS file/code to DOM
let isFile = js.indexOf(".js") > -1
let script = document.createElement("script")
if (isFile) script.src = js
else script.textContent = js
script.type = "text/javascript"
document.body.append(script)
const Append = JS => {
let elem = document.createElement("script")
elem.src = `${ JS }?v=${ Math.random() }`
elem.type = "text/javascript"
document.body.append(elem)
}

Attach()
4 changes: 2 additions & 2 deletions build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turnStyles for turntable.fm",
"version": "11.0.0",
"version": "11.0.1",
"description": "Apply tweaks to turntable.fm - autobop, autodj, themes, styles, and more!",
"manifest_version": 2,
"icons": {
Expand Down Expand Up @@ -36,4 +36,4 @@
"themes/*",
"styles/*"
]
}
}
13 changes: 5 additions & 8 deletions build/styles/blue.css

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions build/styles/green.css

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions build/styles/pink.css

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions build/styles/purple.css

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions build/styles/teal.css

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions build/themes/cosmic.css

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions build/themes/dark.css

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions build/themes/forest.css

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions build/themes/midnight.css

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions build/themes/night.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/turnStyles.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turnStyles for turntable.fm",
"version": "11.0.0",
"version": "11.0.1",
"description": "Apply tweaks to turntable.fm - autobop, autodj, themes, styles, and more!",
"manifest_version": 2,
"icons": {
Expand Down Expand Up @@ -36,4 +36,4 @@
"themes/*",
"styles/*"
]
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turnStyles",
"version": "11.0.0",
"version": "11.0.1",
"main": "turnStyles.js",
"repository": "git@github.com:pixelcrisis/turntable-tweaks.git",
"author": "pixelcrisis <pxcrisis@gmail.com>",
Expand Down

0 comments on commit dffb029

Please sign in to comment.