-
-
Notifications
You must be signed in to change notification settings - Fork 605
use proper messaging - Needs Safari tester #2463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ImprovedTube
wants to merge
6
commits into
master
Choose a base branch
from
recreated2366
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e6bcba
Update core.js use proper messaging
raszpl 648b259
Update core.js message instead of dom
raszpl be200dc
Update init.js proper messages instead of a hack
raszpl 87fadab
Update init.js unneded
raszpl 144b833
Update core.js message passing
raszpl c0a2b9d
Update core.js ff fix
raszpl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,9 +12,6 @@ window.addEventListener('yt-navigate-finish', function () { | |||||
extension.features.thumbnailsQuality(); | ||||||
}); | ||||||
|
||||||
extension.messages.create(); | ||||||
extension.messages.listener(); | ||||||
|
||||||
extension.events.on('init', function (resolve) { | ||||||
extension.storage.listener(); | ||||||
extension.storage.load(function () { | ||||||
|
@@ -115,132 +112,114 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { | |||||
} | ||||||
}); | ||||||
|
||||||
document.addEventListener('it-message-from-youtube', function () { | ||||||
var provider = document.querySelector('#it-messages-from-youtube'); | ||||||
document.addEventListener('it-message-from-youtube', function (message) { | ||||||
message = message.detail; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if (provider) { | ||||||
var message = provider.textContent; | ||||||
if (message.requestOptionsUrl === true) { | ||||||
extension.messages.send({ | ||||||
responseOptionsUrl: chrome.runtime.getURL('menu/index.html') | ||||||
}); | ||||||
} else if (message.onlyOnePlayer === true) { | ||||||
chrome.runtime.sendMessage({ | ||||||
name: 'only-one-player' | ||||||
}); | ||||||
} else if (message.action === 'fixPopup') { | ||||||
chrome.runtime.sendMessage({ | ||||||
action: 'fixPopup', | ||||||
width: message.width, | ||||||
height: message.height, | ||||||
title: message.title, | ||||||
}); | ||||||
} else if (message.action === 'analyzer') { | ||||||
if (extension.storage.data.analyzer_activation === true) { | ||||||
var data = message.name, | ||||||
date = new Date().toDateString(), | ||||||
hours = new Date().getHours() + ':00'; | ||||||
|
||||||
if (!extension.storage.data.analyzer) { | ||||||
extension.storage.data.analyzer = {}; | ||||||
} | ||||||
|
||||||
document.dispatchEvent(new CustomEvent('it-message-from-youtube--readed')); | ||||||
if (!extension.storage.data.analyzer[date]) { | ||||||
extension.storage.data.analyzer[date] = {}; | ||||||
} | ||||||
|
||||||
try { | ||||||
message = JSON.parse(message); | ||||||
} catch (error) { | ||||||
console.log(error); | ||||||
} | ||||||
if (!extension.storage.data.analyzer[date][hours]) { | ||||||
extension.storage.data.analyzer[date][hours] = {}; | ||||||
} | ||||||
|
||||||
//console.log(message); | ||||||
if (!extension.storage.data.analyzer[date][hours][data]) { | ||||||
extension.storage.data.analyzer[date][hours][data] = 0; | ||||||
} | ||||||
|
||||||
if (message.requestOptionsUrl === true) { | ||||||
extension.messages.send({ | ||||||
responseOptionsUrl: chrome.runtime.getURL('menu/index.html') | ||||||
}); | ||||||
} else if (message.onlyOnePlayer === true) { | ||||||
chrome.runtime.sendMessage({ | ||||||
name: 'only-one-player' | ||||||
}); | ||||||
} else if (message.action === 'fixPopup') { | ||||||
chrome.runtime.sendMessage({ | ||||||
action: 'fixPopup', | ||||||
width: message.width, | ||||||
height: message.height, | ||||||
title: message.title, | ||||||
extension.storage.data.analyzer[date][hours][data]++; | ||||||
|
||||||
chrome.storage.local.set({ | ||||||
analyzer: extension.storage.data.analyzer | ||||||
}); | ||||||
} else if (message.action === 'analyzer') { | ||||||
if (extension.storage.data.analyzer_activation === true) { | ||||||
var data = message.name, | ||||||
date = new Date().toDateString(), | ||||||
hours = new Date().getHours() + ':00'; | ||||||
|
||||||
if (!extension.storage.data.analyzer) { | ||||||
extension.storage.data.analyzer = {}; | ||||||
} | ||||||
} | ||||||
} else if (message.action === 'blocklist') { | ||||||
if (!extension.storage.data.blocklist || typeof extension.storage.data.blocklist !== 'object') { | ||||||
extension.storage.data.blocklist = {}; | ||||||
} | ||||||
|
||||||
if (!extension.storage.data.analyzer[date]) { | ||||||
extension.storage.data.analyzer[date] = {}; | ||||||
switch(message.type) { | ||||||
case 'channel': | ||||||
if (!extension.storage.data.blocklist.channels) { | ||||||
extension.storage.data.blocklist.channels = {}; | ||||||
} | ||||||
|
||||||
if (!extension.storage.data.analyzer[date][hours]) { | ||||||
extension.storage.data.analyzer[date][hours] = {}; | ||||||
if (message.added) { | ||||||
extension.storage.data.blocklist.channels[message.id] = { | ||||||
title: message.title, | ||||||
preview: message.preview | ||||||
} | ||||||
} else { | ||||||
delete extension.storage.data.blocklist.channels[message.id]; | ||||||
} | ||||||
break | ||||||
|
||||||
if (!extension.storage.data.analyzer[date][hours][data]) { | ||||||
extension.storage.data.analyzer[date][hours][data] = 0; | ||||||
case 'video': | ||||||
if (!extension.storage.data.blocklist.videos) { | ||||||
extension.storage.data.blocklist.videos = {}; | ||||||
} | ||||||
|
||||||
extension.storage.data.analyzer[date][hours][data]++; | ||||||
|
||||||
chrome.storage.local.set({ | ||||||
analyzer: extension.storage.data.analyzer | ||||||
}); | ||||||
} | ||||||
} else if (message.action === 'blocklist') { | ||||||
if (!extension.storage.data.blocklist || typeof extension.storage.data.blocklist !== 'object') { | ||||||
extension.storage.data.blocklist = {}; | ||||||
} | ||||||
|
||||||
switch(message.type) { | ||||||
case 'channel': | ||||||
if (!extension.storage.data.blocklist.channels) { | ||||||
extension.storage.data.blocklist.channels = {}; | ||||||
} | ||||||
if (message.added) { | ||||||
extension.storage.data.blocklist.channels[message.id] = { | ||||||
title: message.title, | ||||||
preview: message.preview | ||||||
} | ||||||
} else { | ||||||
delete extension.storage.data.blocklist.channels[message.id]; | ||||||
} | ||||||
break | ||||||
|
||||||
case 'video': | ||||||
if (!extension.storage.data.blocklist.videos) { | ||||||
extension.storage.data.blocklist.videos = {}; | ||||||
} | ||||||
if (message.added) { | ||||||
extension.storage.data.blocklist.videos[message.id] = { | ||||||
title: message.title | ||||||
} | ||||||
} else { | ||||||
delete extension.storage.data.blocklist.videos[message.id]; | ||||||
if (message.added) { | ||||||
extension.storage.data.blocklist.videos[message.id] = { | ||||||
title: message.title | ||||||
} | ||||||
break | ||||||
} | ||||||
} else { | ||||||
delete extension.storage.data.blocklist.videos[message.id]; | ||||||
} | ||||||
break | ||||||
} | ||||||
|
||||||
chrome.storage.local.set({ | ||||||
blocklist: extension.storage.data.blocklist | ||||||
}); | ||||||
} else if (message.action === 'watched') { | ||||||
if (!extension.storage.data.watched || typeof extension.storage.data.watched !== 'object') { | ||||||
extension.storage.data.watched = {}; | ||||||
} | ||||||
chrome.storage.local.set({ | ||||||
blocklist: extension.storage.data.blocklist | ||||||
}); | ||||||
} else if (message.action === 'watched') { | ||||||
if (!extension.storage.data.watched || typeof extension.storage.data.watched !== 'object') { | ||||||
extension.storage.data.watched = {}; | ||||||
} | ||||||
|
||||||
if (message.type === 'add') { | ||||||
extension.storage.data.watched[message.id] = { | ||||||
title: message.title | ||||||
}; | ||||||
} | ||||||
if (message.type === 'add') { | ||||||
extension.storage.data.watched[message.id] = { | ||||||
title: message.title | ||||||
}; | ||||||
} | ||||||
|
||||||
if (message.type === 'remove') { | ||||||
delete extension.storage.data.watched[message.id]; | ||||||
} | ||||||
if (message.type === 'remove') { | ||||||
delete extension.storage.data.watched[message.id]; | ||||||
} | ||||||
|
||||||
chrome.storage.local.set({ | ||||||
watched: extension.storage.data.watched | ||||||
}); | ||||||
} else if (message.action === 'set') { | ||||||
if (message.value) { | ||||||
chrome.storage.local.set({[message.key]: message.value}); | ||||||
} else { | ||||||
chrome.storage.local.remove([message.key]); | ||||||
} | ||||||
chrome.storage.local.set({ | ||||||
watched: extension.storage.data.watched | ||||||
}); | ||||||
} else if (message.action === 'set') { | ||||||
if (message.value) { | ||||||
chrome.storage.local.set({[message.key]: message.value}); | ||||||
} else { | ||||||
chrome.storage.local.remove([message.key]); | ||||||
} | ||||||
} else if (message.action === 'play') { | ||||||
chrome.runtime.sendMessage({action: 'play'}); | ||||||
} | ||||||
}); | ||||||
|
||||||
document.addEventListener('it-play', function (event) { | ||||||
var videos = document.querySelectorAll('video'); | ||||||
try {chrome.runtime.sendMessage({action: 'play'})} | ||||||
catch(error){console.log(error); setTimeout(function () { try { chrome.runtime.sendMessage({action: 'play'}, function (response) { console.log(response) } ); } catch { } }, 321) } | ||||||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is
cloneInto
defined?