Skip to content

Commit

Permalink
few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Savinov committed Oct 12, 2019
1 parent d62e536 commit 91034e3
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 28 deletions.
42 changes: 21 additions & 21 deletions 2.0/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"about": {
"message": "About"
},
"saveAs": {
"message": "Save us"
},
"activateCaptions": {
"message": "Activate captions"
},
Expand Down Expand Up @@ -38,9 +35,6 @@
"annotations": {
"message": "Annotations"
},
"hideAnnotations": {
"message": "Hide annotations"
},
"appearance": {
"message": "Appearance"
},
Expand Down Expand Up @@ -110,9 +104,6 @@
"cancel": {
"message": "Cancel"
},
"hideCards": {
"message": "Hide cards"
},
"channel": {
"message": "Channel"
},
Expand Down Expand Up @@ -206,9 +197,6 @@
"enabled": {
"message": "Enabled"
},
"hideEndscreen": {
"message": "Hide endscreen"
},
"expanded": {
"message": "Expanded"
},
Expand All @@ -218,18 +206,12 @@
"extension": {
"message": "Extension"
},
"hideFeaturedContent": {
"message": "Hide featured content"
},
"fitToWindow": {
"message": "Fit to window"
},
"flash": {
"message": "Flash"
},
"hideFooter": {
"message": "Hide footer"
},
"footer": {
"message": "Footer"
},
Expand Down Expand Up @@ -278,12 +260,30 @@
"hideAnimatedThumbnails": {
"message": "Hide animated thumbnails"
},
"hideAnnotations": {
"message": "Hide annotations"
},
"hideCards": {
"message": "Hide cards"
},
"hideDetails": {
"message": "Hide details"
},
"hideEndscreen": {
"message": "Hide endscreen"
},
"hideFeaturedContent": {
"message": "Hide featured content"
},
"hideFooter": {
"message": "Hide footer"
},
"hideRightButtons": {
"message": "Hide right buttons"
},
"hideViewsCount": {
"message": "Hide views count"
},
"history": {
"message": "History"
},
Expand Down Expand Up @@ -494,6 +494,9 @@
"save": {
"message": "Save"
},
"saveAs": {
"message": "Save us"
},
"schedule": {
"message": "Schedule"
},
Expand Down Expand Up @@ -608,9 +611,6 @@
"videos": {
"message": "Videos"
},
"hideViewsCount": {
"message": "Hide views count"
},
"volume": {
"message": "Volume"
},
Expand Down
25 changes: 24 additions & 1 deletion 2.0/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
5.0 Storage change listener
6.0 Initialization
7.0 Uninstall URL
8.0 Google analytics
--------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -286,4 +287,26 @@ chrome.storage.local.get(function(items) {
7.0 Uninstall URL
-----------------------------------------------------------------------------*/

chrome.runtime.setUninstallURL('http://improvedtube.com/uninstalled');
chrome.runtime.setUninstallURL('http://improvedtube.com/uninstalled');


/*-----------------------------------------------------------------------------
8.0 Google analytics
-----------------------------------------------------------------------------*/

if (chrome.runtime.getManifest().version === chrome.runtime.getManifest().version_name) {
var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-88354155-1']);
_gaq.push(['_setSessionCookieTimeout', 14400000]);

(function() {
var ga = document.createElement('script'),
s = document.getElementsByTagName('script')[0];

ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
s.parentNode.insertBefore(ga, s);
})();
}
3 changes: 2 additions & 1 deletion 2.0/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"youtube/js/features/channel.js",
"youtube/js/features/shortcuts.js",
"youtube/js/features/volume-mixer.js",
"youtube/js/features/analyzer.js",
"youtube/js/features/blacklist.js",
"youtube/js/features/settings.js"
],
Expand Down Expand Up @@ -146,7 +147,7 @@
"satus/templates/improvedtube/template-parts/channel.js",
"satus/templates/improvedtube/template-parts/shortcuts.js",
"satus/templates/improvedtube/template-parts/mixer.js",
"satus/templates/improvedtube/template-parts/youtube-time.js",
"satus/templates/improvedtube/template-parts/analyzer.js",
"satus/templates/improvedtube/template-parts/blacklist.js",
"satus/templates/improvedtube/template-parts/settings.js",
"satus/templates/improvedtube/index.js"
Expand Down
8 changes: 8 additions & 0 deletions 2.0/satus/components/js/shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Satus.prototype.components.shortcut = {
component_surface = document.createElement('div'),
component_canvas = document.createElement('div'),
component_section = document.createElement('section'),
component_button_reset = document.createElement('div'),
component_button_cancel = document.createElement('div'),
component_button_save = document.createElement('div');

Expand All @@ -85,10 +86,12 @@ Satus.prototype.components.shortcut = {
component_surface.className = 'satus-dialog__surface satus-dialog__surface_shortcut';
component_canvas.className = 'satus-shortcut__canvas';
component_section.className = 'satus-section satus-section_shortcut';
component_button_reset.className = 'satus-button satus-button_shortcut';
component_button_cancel.className = 'satus-button satus-button_shortcut';
component_button_save.className = 'satus-button satus-button_shortcut';

component_dialog_label.innerText = component_label.innerText;
component_button_reset.innerText = self.storage.get('locale/reset');
component_button_cancel.innerText = self.storage.get('locale/cancel');
component_button_save.innerText = self.storage.get('locale/save');

Expand Down Expand Up @@ -140,12 +143,17 @@ Satus.prototype.components.shortcut = {
}

component_scrim.addEventListener('click', close);
component_button_reset.addEventListener('click', function() {
self.storage.remove(name);
close();
});
component_button_cancel.addEventListener('click', close);
component_button_save.addEventListener('click', function() {
self.storage.set(name, JSON.stringify(value));
close(false);
});

component_section.appendChild(component_button_reset);
component_section.appendChild(component_button_cancel);
component_section.appendChild(component_button_save);

Expand Down
9 changes: 7 additions & 2 deletions 2.0/satus/components/js/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Satus.prototype.components.switch = {
get: function(name, object) {
var self = this,
component = document.createElement('div'),
label = this.storage.get('locale/' + object.label) || this.storage.get('locale/' + name) || object.label;
label = this.storage.get('locale/' + object.label) || this.storage.get('locale/' + name) || object.label,
stor = this.storage.get((object.storage_path || '') + '/' + name);

object.tabindex = true;

Expand All @@ -21,7 +22,11 @@ Satus.prototype.components.switch = {
((object.icons || {}).start || '') + '<div class=track><div class=thumb></div></div>' + ((object.icons || {}).end || '') +
'</div>';

component.dataset.value = this.storage.get((object.storage_path || '') + '/' + name) || object.value || false;
component.dataset.value = object.value || false;

if (this.storage.has(name)) {
component.dataset.value = stor;
}

component.addEventListener('click', function(event) {
if (component.dataset.value == 'true') {
Expand Down
40 changes: 40 additions & 0 deletions 2.0/satus/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function Satus(query, options = {}) {
storage: {
get: [],
set: [],
remove: [],
clear: []
},
components: {
Expand Down Expand Up @@ -69,6 +70,12 @@ function Satus(query, options = {}) {
}
});

Object.defineProperty(this.storage, 'onremove', {
value: function(callback) {
event_listeners.storage.remove.push(callback);
}
});

Object.defineProperty(this.storage, 'onclear', {
value: function(callback) {
event_listeners.storage.clear.push(callback);
Expand Down Expand Up @@ -106,6 +113,7 @@ function Satus(query, options = {}) {

Object.defineProperty(this.storage, 'has', {
value: function(name) {
console.log(name, storage.hasOwnProperty(name), storage);
return storage.hasOwnProperty(name);
}
});
Expand Down Expand Up @@ -142,6 +150,38 @@ function Satus(query, options = {}) {
}
});

Object.defineProperty(this.storage, 'remove', {
value: function(name, path) {
if (typeof path === 'string') {
let path_array_before = path.split('/'),
path_array = [],
storage_link = storage;

for (let i = 0, l = path_array_before.length; i < l; i++) {
if (path_array_before[i] != '') {
path_array.push(path_array_before[i]);
}
}

for (let i = 0, l = path_array.length; i < l; i++) {
if (!storage_link.hasOwnProperty(path_array[i])) {
storage_link[path_array[i]] = {};
}

storage_link = storage_link[path_array[i]];
}

delete storage_link[name];
} else {
delete storage[name];
}

for (var i in event_listeners.storage.remove) {
event_listeners.storage.remove[i](name, storage);
}
}
});

Object.defineProperty(this.storage, 'clear', {
value: function() {
storage = {};
Expand Down
2 changes: 1 addition & 1 deletion 2.0/satus/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<script src="templates/improvedtube/template-parts/channel.js"></script>
<script src="templates/improvedtube/template-parts/shortcuts.js"></script>
<script src="templates/improvedtube/template-parts/mixer.js"></script>
<script src="templates/improvedtube/template-parts/youtube-time.js"></script>
<script src="templates/improvedtube/template-parts/analyzer.js"></script>
<script src="templates/improvedtube/template-parts/blacklist.js"></script>
<script src="templates/improvedtube/template-parts/settings.js"></script>
<script src="templates/improvedtube/index.js"></script>
Expand Down
29 changes: 29 additions & 0 deletions 2.0/satus/modules/js/chromium-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Satus.prototype.modules.chromium_storage = {
self.set(name, value, storage);
});

self.storage.onremove(function(name, storage) {
self.remove(name, storage);
});

self.storage.onclear(function() {
self.clear();
});
Expand Down Expand Up @@ -50,6 +54,31 @@ Satus.prototype.modules.chromium_storage = {
}
},

remove: function(name, old_storage) {
var new_storage = {},
message = {
name: name,
value: null,
storage: this.storage.get()
},
exclude = this.getOption('chromium_storage').exclude;

chrome.storage.local.clear();
chrome.storage.local.set(old_storage);

if (Object.keys(message).length > 0) {
if (chrome && chrome.tabs) {
chrome.tabs.query({}, function(tabs) {
for (var i = 0, l = tabs.length; i < l; i++) {
if (tabs[i].hasOwnProperty('url')) {
chrome.tabs.sendMessage(tabs[i].id, message);
}
}
});
}
}
},

clear: function() {
chrome.storage.local.clear();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Satus.prototype.menu.main.youtube_time = {
Satus.prototype.menu.main.analyzer = {
type: 'directory',
label: 'analyzer',
icon: '<svg xmlns=//www.w3.org/2000/svg viewBox="0 0 24 24"><defs><path id="a" d="M0 0h24v24H0z"/></defs><defs><path id="b" d="M0 0h24v24H0z"/></defs><path d="M23 8a2 2 0 0 1-2.51 1.93l-3.56 3.55A2 2 0 0 1 15 16a2 2 0 0 1-1.93-2.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56A2 2 0 0 1 3 18c-1.1 0-2-.9-2-2a2 2 0 0 1 2.51-1.93l4.56-4.55A2 2 0 0 1 10 7a2 2 0 0 1 1.93 2.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56A2 2 0 0 1 21 6a2 2 0 0 1 2 2zm0 0a2 2 0 0 1-2.51 1.93l-3.56 3.55A2 2 0 0 1 15 16a2 2 0 0 1-1.93-2.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56A2 2 0 0 1 3 18c-1.1 0-2-.9-2-2a2 2 0 0 1 2.51-1.93l4.56-4.55A2 2 0 0 1 10 7a2 2 0 0 1 1.93 2.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56A2 2 0 0 1 21 6a2 2 0 0 1 2 2z"></svg>',
Expand Down
2 changes: 1 addition & 1 deletion 2.0/youtube/js/features/analyzer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ImprovedTube.videoUrl = '';
ImprovedTube.videoUrl = '"null"';
ImprovedTube.playingTime = 0;

document.addEventListener('ImprovedTubeAnalyzer', function() {
Expand Down

0 comments on commit 91034e3

Please sign in to comment.