Skip to content

Commit

Permalink
Merge pull request #184 from aopell/develop
Browse files Browse the repository at this point in the history
Version 6.2.1
  • Loading branch information
aopell authored May 28, 2020
2 parents 1d60a43 + 8413180 commit 0fa2b0a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
15 changes: 13 additions & 2 deletions .build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
class BuildRules:
def __init__(self, config):
self.excluded_files = config["excluded_files"] or []
self.properties = config["properties"] or {}

EXCLUDED_FILES = [".build", ".git", ".github", ".vscode", "SchoologyPlus.zip", "webstore-description.txt"]

chrome_rules = BuildRules({
"excluded_files": []
"excluded_files": [],
"properties": {
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'"
}
})

firefox_rules = BuildRules({
"excluded_files": [
"lib/js/analytics.js"
]
],
"properties": { }
})

targets = {
Expand Down Expand Up @@ -82,7 +87,13 @@ def copyFileOrDirectory(src, dst):
targetManifest = copy.deepcopy(manifest)

for path in rules.excluded_files:
print(f"Removing path {path}")
removePathFromManifest(targetManifest, path)
if os.path.exists(f".build/{target}/{path}"):
os.remove(f".build/{target}/{path}")

print("Copying properties")
targetManifest.update(rules.properties)

with open(f".build/{target}/manifest.json", "w") as manifestFile:
manifestFile.write(json.dumps(targetManifest, indent=4))
Expand Down
9 changes: 5 additions & 4 deletions js/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ var trackEvent = function (target, action, label = undefined, value = undefined)
}
}

chrome.storage.sync.get({ analytics: getBrowser() === "Firefox" ? "disabled" : "enabled" }, s => {
chrome.storage.sync.get({ analytics: getBrowser() === "Firefox" ? "disabled" : "enabled", theme: "<unset>" }, s => {
if (s.analytics === "enabled") {
enableAnalytics();
enableAnalytics(s.theme);
}
});

function enableAnalytics() {
function enableAnalytics(selectedTheme) {
// isogram
let r = 'ga';
window['GoogleAnalyticsObject'] = r;
Expand All @@ -44,7 +44,8 @@ var trackEvent = function (target, action, label = undefined, value = undefined)
ga('set', 'checkProtocolTask', null); // Disable file protocol checking.
ga('set', 'dimension1', chrome.runtime.getManifest().version);
ga('set', 'dimension2', location.host);
ga('send', 'pageview', location.pathname + location.search);
ga('set', 'dimension3', selectedTheme);
ga('send', 'pageview', location.pathname.replace(/\/\d{3,}\b/g, "/*") + location.search);

trackEvent = function (target, action, label = undefined, value = undefined) {
ga('send', 'event', target, action, label, value);
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"id": "[email protected]"
}
},
"version": "6.2",
"version": "6.2.1",
"icons": {
"128": "imgs/[email protected]",
"64": "imgs/[email protected]",
Expand Down Expand Up @@ -42,7 +42,7 @@
"theme-editor.html",
"default-icons.html"
],
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
"content_security_policy": "script-src 'self'; object-src 'self'",
"background": {
"scripts": [
"js/analytics.js",
Expand Down

0 comments on commit 0fa2b0a

Please sign in to comment.