Skip to content

Commit

Permalink
Removed v3.120-pre
Browse files Browse the repository at this point in the history
  • Loading branch information
adokseo committed Dec 28, 2020
1 parent eb45306 commit 145f273
Show file tree
Hide file tree
Showing 44 changed files with 36,288 additions and 0 deletions.
809 changes: 809 additions & 0 deletions _locales/ar/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/bn/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/de/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/el/messages.json

Large diffs are not rendered by default.

812 changes: 812 additions & 0 deletions _locales/en/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/es/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/fr/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/hin/messages.json

Large diffs are not rendered by default.

806 changes: 806 additions & 0 deletions _locales/id/messages.json

Large diffs are not rendered by default.

806 changes: 806 additions & 0 deletions _locales/it/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/ja/messages.json

Large diffs are not rendered by default.

806 changes: 806 additions & 0 deletions _locales/ko/messages.json

Large diffs are not rendered by default.

812 changes: 812 additions & 0 deletions _locales/nb_NO/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/nl/messages.json

Large diffs are not rendered by default.

800 changes: 800 additions & 0 deletions _locales/no/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/pt_BR/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/pt_PT/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/ru/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/sk/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/tr/messages.json

Large diffs are not rendered by default.

815 changes: 815 additions & 0 deletions _locales/zh_CN/messages.json

Large diffs are not rendered by default.

809 changes: 809 additions & 0 deletions _locales/zh_TW/messages.json

Large diffs are not rendered by default.

Binary file added assets/fonts/OpenSans-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/OpenSans-SemiBold.ttf
Binary file not shown.
Binary file added assets/icons/128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/128g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/16g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/32g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/48g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
368 changes: 368 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,368 @@
/*---------------------------------------------------------------
>>> BACKGROUND
-----------------------------------------------------------------
# Global variables
# Functions
# Context menu items
# Message listener
# Storage change listener
# Initialization
# Uninstall URL
# Google Analytics
---------------------------------------------------------------*/

/*---------------------------------------------------------------
# GLOBAL VARIABLES
---------------------------------------------------------------*/

var locale_code = 'en',
browser_icon = false;


/*---------------------------------------------------------------
# FUNCTIONS
---------------------------------------------------------------*/

function isset(variable) {
if (typeof variable === 'undefined' || variable === null) {
return false;
}

return true;
}

function getTranslations(path) {
var xhr = new XMLHttpRequest();

xhr.addEventListener('load', function() {
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, {
name: 'translation_response',
value: xhr.responseText
});
}
}
});
}

chrome.runtime.sendMessage({
name: 'translation_response',
value: xhr.responseText
});
});

xhr.open('GET', path, true);
xhr.send();
}

function browserActionIcon() {
if (browser_icon === 'always') {
chrome.browserAction.setIcon({
path: 'assets/icons/32.png'
});
} else {
chrome.browserAction.setIcon({
path: 'assets/icons/32g.png'
});
}
}


/*---------------------------------------------------------------
# CONTEXT MENU ITEMS
---------------------------------------------------------------*/

chrome.contextMenus.removeAll();

chrome.contextMenus.create({
id: '1111',
title: 'Donate',
contexts: ['browser_action']
});

chrome.contextMenus.create({
id: '1112',
title: 'Rate me',
contexts: ['browser_action']
});

chrome.contextMenus.create({
id: '1113',
title: 'GitHub',
contexts: ['browser_action']
});

chrome.contextMenus.onClicked.addListener(function(event) {
if (event.menuItemId === '1111') {
window.open('https://www.improvedtube.com/donate');
} else if (event.menuItemId === '1112') {
window.open('https://chrome.google.com/webstore/detail/improvedtube-for-youtube/bnomihfieiccainjcjblhegjgglakjdd');
} else if (event.menuItemId === '1113') {
window.open('https://github.com/ImprovedTube/ImprovedTube');
}
});


/*---------------------------------------------------------------
# MESSAGE LISTENER
---------------------------------------------------------------*/

chrome.runtime.onMessage.addListener(function(request, sender) {
if (isset(request) && typeof request === 'object') {
if (request.enabled === true && browser_icon !== 'always') {
chrome.browserAction.setIcon({
path: 'assets/icons/32.png',
tabId: sender.tab.id
});
}

if (request.name === 'translation_request') {
getTranslations(request.path);
}

if (request.name === 'improvedtube-analyzer') {
var data = request.value,
date = new Date().toDateString(),
hours = new Date().getHours() + ':00';

chrome.storage.local.get(function(items) {
if (!items.analyzer) {
items.analyzer = {};
}

if (!items.analyzer[date]) {
items.analyzer[date] = {};
}

if (!items.analyzer[date][hours]) {
items.analyzer[date][hours] = {};
}

if (!items.analyzer[date][hours][data]) {
items.analyzer[date][hours][data] = 0;
}

items.analyzer[date][hours][data]++;

chrome.storage.local.set({
analyzer: items.analyzer
});
});
}

if (request.name === 'improvedtube-blacklist') {
chrome.storage.local.get(function(items) {
if (!items.blacklist || typeof items.blacklist !== 'object') {
items.blacklist = {};
}

if (request.data.type === 'channel') {
if (!items.blacklist.channels) {
items.blacklist.channels = {};
}

items.blacklist.channels[request.data.id] = {
title: request.data.title,
preview: request.data.preview
};
}

if (request.data.type === 'video') {
if (!items.blacklist.videos) {
items.blacklist.videos = {};
}

items.blacklist.videos[request.data.id] = {
title: request.data.title
};
}

chrome.storage.local.set({
blacklist: items.blacklist
});
});
}

if (request.name === 'improvedtube-watched') {
chrome.storage.local.get(function(items) {
if (!items.watched || typeof items.watched !== 'object') {
items.watched = {};
}

if (request.data.action === 'set') {
items.watched[request.data.id] = {
title: request.data.title
};
}

if (request.data.action === 'remove') {
delete items.watched[request.data.id];
}

chrome.storage.local.set({
watched: items.watched
});
});
}

if (request.name === 'download') {
chrome.permissions.request({
permissions: ['downloads'],
origins: ['https://www.youtube.com/*']
}, function(granted) {
if (granted) {
try {
var blob = new Blob([JSON.stringify(request.value)], {
type: 'application/json;charset=utf-8'
});

chrome.downloads.download({
url: URL.createObjectURL(blob),
filename: request.filename,
saveAs: true
});
} catch (err) {
chrome.runtime.sendMessage({
name: 'dialog-error',
value: err
});
}
} else {
chrome.runtime.sendMessage({
name: 'dialog-error',
value: 'permissionIsNotGranted'
});
}
});
}

if (request.name === 'improvedtube-play') {
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, {
name: 'improvedtube-play',
id: request.id
});
}
}
});
}

if (isset(request.export)) {
chrome.storage.local.get(function(data) {
chrome.permissions.request({
permissions: ['downloads'],
origins: ['https://www.youtube.com/*']
}, function(granted) {
if (granted) {
var blob = new Blob([JSON.stringify(data)], {
type: 'application/octet-stream'
}),
date = new Date();

chrome.downloads.download({
url: URL.createObjectURL(blob),
filename: 'improvedtube_' + (date.getMonth() + 1) + '_' + date.getDate() + '_' + date.getFullYear() + '.json',
saveAs: true
});
}
});
});
}
}
});


/*---------------------------------------------------------------
# STORAGE CHANGE LISTENER
---------------------------------------------------------------*/

chrome.storage.onChanged.addListener(function(changes) {
if (isset(changes.improvedtube_language)) {
locale_code = changes.improvedtube_language.newValue;
}

if (isset(changes.improvedtube_browser_icon)) {
browser_icon = changes.improvedtube_browser_icon.newValue;
}

browserActionIcon();

_gaq.push(['_trackPageview', '/improvedtube-' + chrome.runtime.getManifest().version + '/background', 'page-loaded']);
});


/*---------------------------------------------------------------
# INITIALIZATION
---------------------------------------------------------------*/

chrome.storage.local.get(function(items) {
if (isset(items.improvedtube_language)) {
locale_code = items.improvedtube_language;
}

if (isset(items.improvedtube_browser_icon)) {
browser_icon = items.improvedtube_browser_icon;
}

browserActionIcon();

_gaq.push(['_trackPageview', '/improvedtube-' + chrome.runtime.getManifest().version + '/background', 'page-loaded']);
});


/*---------------------------------------------------------------
# UNINSTALL URL
---------------------------------------------------------------*/

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


/*---------------------------------------------------------------
# GOOGLE ANALYTICS
---------------------------------------------------------------*/

var _gaq = _gaq || [];

/*(function() {
var ga = document.createElement('script');
_gaq.push(['_setAccount', 'UA-88354155-1']);
_gaq.push(['_setSessionCookieTimeout', 14400000]);
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
document.body.appendChild(ga);
})();*/









chrome.tabs.onActivated.addListener(function(activeInfo) {
chrome.tabs.query({}, function(tabs) {
chrome.tabs.sendMessage(activeInfo.tabId, {
action: 'focus'
});

for (var i = 0, l = tabs.length; i < l; i++) {
if (tabs[i].id !== activeInfo.tabId) {
if (tabs[i].hasOwnProperty('url')) {
chrome.tabs.sendMessage(tabs[i].id, {
action: 'blur'
});
}
}
}
});
});

0 comments on commit 145f273

Please sign in to comment.