Skip to content

Commit

Permalink
Build v10.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelcrisis committed Mar 29, 2022
1 parent 1100d46 commit 59e9d68
Show file tree
Hide file tree
Showing 6 changed files with 1,962 additions and 75 deletions.
55 changes: 27 additions & 28 deletions build/inject.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
const ext = chrome || browser
const url = ext.runtime.getURL("turnStyles.js")
let core = chrome || browser
let tsdb = window.localStorage.getItem("tsdb")
let wipe = window.localStorage.getItem("ts-reset")
let sync = core.storage ? core.storage.sync : false
if (sync && wipe) window.localStorage.removeItem("ts-reset")

const inject = () => {
// inject url base into the window
// this tells the script we're an extension
const path = url.split("/turnStyles.js")[0]
const base = document.createElement("script")
base.textContent = `window.tsBase = "${path}"`
base.type = "text/javascript"
document.body.append(base)
const append = js => {
let file = js.indexOf(".js") > -1
let elem = document.createElement("script")
if (file) elem.src = js
else elem.textContent = js
elem.type = "text/javascript"
document.body.append(elem)
}

// inject the main turnStyles script
const main = document.createElement("script")
main.type = "text/javascript"
main.src = url
document.body.append(main)
const inject = sync => {
let file = core.runtime.getURL("turnStyles.js")
let base = file.split("/turnStyles.js")[0]
// inject link base into the window
// tells the script we're an extension
append(`window.tsBase = "${ base }"`)
// if we got a backup, inject that too
if (sync) append(`window.tsSync = ${ sync }`)
append(file)
}

const sync = () => {
let local = window.localStorage.getItem("tsdb")
if (local) ext.storage.sync.set({ tsdb: JSON.parse(local) })
ext.storage.sync.get([ "tsdb" ], result => {
let store = result.tsdb ? JSON.stringify(result.tsdb) : ""
const data = document.createElement("script")
data.textContent = `window.tsSync = ${ store }`
data.type = "text/javascript"
document.body.append(data)
inject()
})
const backup = () => {
if (tsdb) sync.set({ tsdb: JSON.parse(tsdb) })
if (wipe) sync.remove([ "tsdb" ], db => inject())
else sync.get([ "tsdb" ], db => inject(JSON.stringify(db.tsdb || {})))
}

const init = () => {
if (!ext.storage) inject()
else sync()
return sync ? backup() : inject()
}

init()
19 changes: 13 additions & 6 deletions build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "turnStyles for turntable.fm",
"version": "10.6.0",
"version": "10.6.1",
"description": "Apply tweaks to turntable.fm - autobop, autodj, themes, styles, and more!",
"manifest_version": 2,
"icons": {
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"permissions": [ "notifications", "storage" ],
"permissions": [
"notifications",
"storage"
],
"content_scripts": [
{
"exclude_globs": [
Expand All @@ -18,15 +21,19 @@
"*://turntable.fm/terms",
"*://turntable.fm/static/*"
],
"js": [ "inject.js" ],
"js": [
"inject.js"
],
"run_at": "document_end",
"matches": [ "*://turntable.fm/*" ]
"matches": [
"*://turntable.fm/*"
]
}
],
"web_accessible_resources": [
"web_accessible_resources": [
"turnStyles.css",
"turnStyles.js",
"themes/*",
"styles/*"
]
}
}
77 changes: 39 additions & 38 deletions build/turnStyles.css

Large diffs are not rendered by default.

1,882 changes: 1,881 additions & 1 deletion build/turnStyles.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turnStyles for turntable.fm",
"version": "10.6.0",
"version": "10.6.1",
"description": "Apply tweaks to turntable.fm - autobop, autodj, themes, styles, and more!",
"manifest_version": 2,
"icons": {
Expand Down
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": "10.6.0",
"version": "10.6.1",
"main": "turnStyles.js",
"repository": "[email protected]:pixelcrisis/turntable-tweaks.git",
"author": "pixelcrisis <[email protected]>",
Expand Down

0 comments on commit 59e9d68

Please sign in to comment.