Compare commits

...

2 Commits

Author SHA1 Message Date
Florian Metz
f4e15215ec 📝 v1.3.2.1 2019-08-29 13:12:01 +02:00
Florian Metz
b57cc559d9 📝 Version 1.3.2 2019-08-29 12:38:58 +02:00
5 changed files with 138 additions and 326 deletions

View File

@@ -209,19 +209,6 @@
</div>
</td>
</tr>
<tr>
<td><h5 id="pMiDOption">Rabb.it</h5></td>
<td>
<div class="switch">
<label>
<input
type="checkbox"
class="toggleRabbit rabbit"
/><span class="lever"></span>
</label>
</div>
</td>
</tr>
<tr>
<td><h5 id="pMiDOption">Crunchyroll</h5></td>
<td>
@@ -235,32 +222,6 @@
</div>
</td>
</tr>
<tr>
<td><h5 id="pMiDOption">Aniflix</h5></td>
<td>
<div class="switch">
<label>
<input
type="checkbox"
class="toggleAniflix aniflix"
/><span class="lever"></span>
</label>
</div>
</td>
</tr>
<tr>
<td><h5 id="pMiDOption">Anime4You</h5></td>
<td>
<div class="switch">
<label>
<input
type="checkbox"
class="toggleAnime4You anime4you"
/><span class="lever"></span>
</label>
</div>
</td>
</tr>
</table>
</div>
</div>

View File

@@ -1,71 +0,0 @@
var playback = false,
videoTitle,
videoAuthor,
videoTimestamps,
playbackBoolean,
smallImageKey,
smallImageText
/**
* Updates the Presence data and sends it back
* to the background.js for further interaction
*/
async function updateData() {
playback =
document.location.pathname.includes("/stream/")
&& iframe_video != null
&& iframe_video.dur != null
? true : false
//* If page has all required propertys
if(playback) {
if($('.entry-title').html().match(new RegExp(" Der Film "), "") != null) {
videoTitle = $('.entry-title').html().replace(new RegExp(" Der Film .*"), "")
videoAuthor = $('.entry-title').html().match(new RegExp("Der Film .*"), "")
} else if($('.entry-title').html().match(new RegExp(" OVA "), "") != null) {
videoTitle = $('.entry-title').html().replace(new RegExp(" OVA .*"), "")
videoAuthor = $('.entry-title').html().match(new RegExp("OVA .*"), "");
} else if($('.entry-title').html().match(new RegExp(" Folge [0-9]*"), "") != " Folge ") {
videoTitle = $('.entry-title').html().replace(new RegExp(" Folge [0-9]* .*"), "")
videoAuthor = $('.entry-title').html().match(new RegExp(" Folge [0-9]* .*"), "")
} else if($('.entry-title').html().match(new RegExp(" Spezial Folge"), "") != null) {
videoTitle = $('.entry-title').html().replace(new RegExp(" Spezial Folge .*"), "")
videoAuthor = $('.entry-title').html().match(new RegExp(" Spezial Folge .*"), "")
} else if($('.entry-title').html().match(new RegExp(" Folge "), "") != null) {
videoTitle = $('.entry-title').html().replace(new RegExp(" Folge .*"), "")
videoAuthor = $('.entry-title').html().match(new RegExp(" Folge .*"), "")
}
videoTimestamps = getTimestamps(Math.floor(iframe_video.curr), Math.floor(iframe_video.dur))
playbackBoolean = !iframe_video.paused
smallImageKey = playbackBoolean ? 'play' : 'pause'
smallImageText = playbackBoolean ? await getString("presence.playback.playing") : await getString("presence.playback.paused")
var data = {
clientID: '521104874738417664',
presenceData: {
details: $('<div/>').html(videoTitle).text(),
state: $('<div/>').html(videoAuthor).text(),
largeImageKey: 'aniflix_lg',
largeImageText: chrome.runtime.getManifest().name + ' V' + chrome.runtime.getManifest().version,
smallImageKey: smallImageKey,
smallImageText: smallImageText,
},
trayTitle: $('<div/>').html(videoTitle).text(),
playback: playbackBoolean,
service: 'Aniflix'
}
if(playbackBoolean) {
data.presenceData.startTimestamp = videoTimestamps[0]
data.presenceData.endTimestamp = videoTimestamps[1]
} else {
delete data.presenceData.startTimestamp
delete data.presenceData.endTimestamp
}
chrome.runtime.sendMessage({presence: data})
}
}

View File

@@ -1,95 +0,0 @@
var playback = false,
videoTitle,
videoAuthor,
videoTimestamps,
playbackBoolean,
smallImageKey,
smallImageText,
urlForVideo,
lastURL = null,
startTimeStamp
/**
* Updates the Presence data and sends it back
* to the background.js for further interaction
*/
async function updateData() {
urlForVideo = document.location.href;
if (urlForVideo != lastURL) {
lastURL = urlForVideo;
startTimeStamp = Math.floor(Date.now() / 1000);
}
playback =
$('.titleshow h1').text().trim() != ""
&& iframe_video.dur != null ? true : false
//* If page has all required propertys
if(playback) {
videoTitle = $('.titleshow h1').html()
videoAuthor = (await getString("presence.episode")).replace("{{episode}}", $('.episoden a.active').text()),
videoTimestamps = getTimestamps(Math.floor(iframe_video.curr), Math.floor(iframe_video.dur))
playbackBoolean = !iframe_video.paused
smallImageKey = playbackBoolean ? 'play' : 'pause'
smallImageText = playbackBoolean ? await getString("presence.playback.playing") : await getString("presence.playback.paused")
var data = {
clientID: '517148876273090577',
presenceData: {
details: $('<div/>').html(videoTitle).text(),
state: $('<div/>').html(videoAuthor).text(),
largeImageKey: 'a4y_lg',
largeImageText: chrome.runtime.getManifest().name + ' V' + chrome.runtime.getManifest().version,
smallImageKey: smallImageKey,
smallImageText: smallImageText,
},
trayTitle: $('<div/>').html(videoTitle).text(),
playback: playbackBoolean,
service: 'Anime4You'
}
if(playbackBoolean) {
data.presenceData.startTimestamp = videoTimestamps[0]
data.presenceData.endTimestamp = videoTimestamps[1]
} else {
delete data.presenceData.startTimestamp
delete data.presenceData.endTimestamp
}
} else if(!document.location.pathname.includes('/show/')) {
var data = {
clientID: '517148876273090577',
presenceData: {
details: await getString('presence.lookingForAnime'),
largeImageKey: 'a4y_lg',
largeImageText: chrome.runtime.getManifest().name + ' V' + chrome.runtime.getManifest().version,
startTimestamp: startTimeStamp
},
trayTitle: $('<div/>').html(videoTitle).text(),
playback: true,
service: 'Anime4You'
}
} else if(document.location.pathname.includes('/show/')) {
var videoTitle = $('.titleshow h1').text().trim(),
videoEpisode = (await getString("presence.episode").replace("{{episode}}", $('.episoden a.active').text()))
var data = {
clientID: '517148876273090577',
presenceData: {
details: $('<div/>').html(videoTitle).text(),
state: $('<div/>').html(videoEpisode).text(),
largeImageKey: 'a4y_lg',
largeImageText: chrome.runtime.getManifest().name + ' V' + chrome.runtime.getManifest().version,
startTimestamp: startTimeStamp
},
trayTitle: $('<div/>').html(videoTitle).text(),
playback: true,
service: 'Anime4You'
}
}
chrome.runtime.sendMessage({presence: data})
}

View File

@@ -1,29 +1,31 @@
var playback = false,
videoTitle,
videoAuthor,
videoTimestamps,
playbackBoolean,
liveBoolean,
startTimestamp,
smallImageKey,
smallImageText
videoTitle,
videoAuthor,
videoTimestamps,
playbackBoolean,
liveBoolean,
startTimestamp,
smallImageKey,
smallImageText;
/**
* Handles Media Key controls
* @param {data} data Data passed by socketConnector.js
*/
async function handleMediaKeys(data) {
if(playback) {
if (playback) {
switch (data.mediaKeys) {
case "pause":
playbackBoolean ? $('.video-stream')[0].pause() : $('.video-stream')[0].play()
break
playbackBoolean
? $(".video-stream")[0].pause()
: $(".video-stream")[0].play();
break;
case "nextTrack":
$('.ytp-next-button')[0].click()
break
$(".ytp-next-button")[0].click();
break;
case "previousTrack":
$('.ytp-prev-button')[0].click()
break
$(".ytp-prev-button")[0].click();
break;
}
}
}
@@ -33,47 +35,70 @@ async function handleMediaKeys(data) {
* to the background.js for further interaction
*/
async function updateData() {
playback =
document.location.pathname.includes("/watch")
&& $('.ytd-video-primary-info-renderer .title').text() != ""
&& $('.video-stream')[0] != undefined
&& !isNaN($('.video-stream')[0].duration)
? true : false
playback =
document.location.pathname.includes("/watch") &&
$(".ytd-video-primary-info-renderer .title").text() != "" &&
$(".video-stream")[0] != undefined &&
!isNaN($(".video-stream")[0].duration)
? true
: false;
//* If page has all required propertys
if(playback) {
if(!startTimestamp) startTimestamp = Math.floor(Date.now() / 1000)
videoTitle = $('.ytd-video-primary-info-renderer .title').text()
videoAuthor = $(".ytd-channel-name a").text()
videoTimestamps = getTimestamps(Math.floor($('.video-stream')[0].currentTime), Math.floor($('.video-stream')[0].duration))
playbackBoolean = !$('.video-stream')[0].paused
liveBoolean = Boolean($('.ytp-live')[0])
smallImageKey = playbackBoolean ? 'play' : 'pause'
smallImageText = playbackBoolean ? await getString("presence.playback.playing") : await getString("presence.playback.paused")
if (playback) {
if (!startTimestamp) startTimestamp = Math.floor(Date.now() / 1000);
videoTitle = $(".ytd-video-primary-info-renderer .title").text();
videoAuthor =
$("#upload-info .style-scope .ytd-video-owner-renderer")
.contents()
.first()
.html() ||
$(".ytd-channel-name a").text() ||
document.querySelector("#owner-name a").innerText;
videoTimestamps = getTimestamps(
Math.floor($(".video-stream")[0].currentTime),
Math.floor($(".video-stream")[0].duration)
);
playbackBoolean = !$(".video-stream")[0].paused;
liveBoolean = Boolean($(".ytp-live")[0]);
smallImageKey = playbackBoolean ? "play" : "pause";
smallImageText = playbackBoolean
? await getString("presence.playback.playing")
: await getString("presence.playback.paused");
var data = {
clientID: '463097721130188830',
clientID: "463097721130188830",
presenceData: {
details: $('<div/>').html(videoTitle).text(),
state: $('<div/>').html(videoAuthor).text(),
largeImageKey: 'yt_lg',
largeImageText: chrome.runtime.getManifest().name + ' V' + chrome.runtime.getManifest().version,
details: $("<div/>")
.html(videoTitle)
.text(),
state: $("<div/>")
.html(videoAuthor)
.text(),
largeImageKey: "yt_lg",
largeImageText:
chrome.runtime.getManifest().name +
" V" +
chrome.runtime.getManifest().version,
smallImageKey: smallImageKey,
smallImageText: smallImageText,
smallImageText: smallImageText
},
trayTitle: $('<div/>').html(videoTitle).text(),
trayTitle: $("<div/>")
.html(videoTitle)
.text(),
playback: playbackBoolean,
service: 'YouTube'
}
service: "YouTube"
};
if(playbackBoolean) {
data.presenceData.startTimestamp = liveBoolean ? startTimestamp : videoTimestamps[0]
if(!liveBoolean) data.presenceData.endTimestamp = videoTimestamps[1]
if (playbackBoolean) {
data.presenceData.startTimestamp = liveBoolean
? startTimestamp
: videoTimestamps[0];
if (!liveBoolean) data.presenceData.endTimestamp = videoTimestamps[1];
} else {
delete data.presenceData.startTimestamp
delete data.presenceData.endTimestamp
delete data.presenceData.startTimestamp;
delete data.presenceData.endTimestamp;
}
chrome.runtime.sendMessage({presence: data})
chrome.runtime.sendMessage({ presence: data });
}
}

View File

@@ -1,78 +1,70 @@
{
"name": "PreMiD",
"author": "Timeraa & Fruxh",
"description": "__MSG_description__",
"default_locale": "en",
"version": "1.3.1.9",
"manifest_version": 2,
"web_accessible_resources": [ "icon.png", "languages/*.json" ],
"browser_action": {
"default_popup": "html/popup.html",
"default_icon": {
"1024": "icon.png"
}
},
"icons": {
"1024": "icon.png"
},
"background": {
"scripts": [ "js/util/socket.io-2.1.1.min.js", "js/background.js" ]
},
"content_scripts": [
{
"matches": [ "<all_urls>" ],
"js": [ "js/util/jquery-3.3.1.min.js", "js/util/socketConnector.js", "js/util/langManager.js" ],
"css": [ "css/connect.css" ]
},
{
"matches": [ "<all_urls>" ],
"js": [ "js/util/jquery-3.3.1.min.js", "js/presences/iframeWitch.js" ],
"all_frames": true
},
{
"matches": [ "*://www.youtube.com/*" ],
"js": [ "js/presences/Video/YouTube.js" ]
},
{
"matches": [ "*://music.youtube.com/*" ],
"js": [ "js/presences/Music/YouTube_Music.js" ]
},
{
"matches": [ "*://soundcloud.com/*" ],
"js": [ "js/presences/Music/SoundCloud.js" ]
},
{
"matches": [ "*://www.netflix.com/*" ],
"js": [ "js/presences/Video/Netflix.js" ]
},
{
"matches": [ "*://www.aniflix.tv/*" ],
"js": [ "js/presences/Anime/Aniflix.js" ]
},
{
"matches": [ "*://www.anime4you.one/*" ],
"js": [ "js/presences/Anime/Anime4You.js" ]
},
{
"matches": [ "*://www.twitch.tv/*" ],
"js": [ "js/presences/Video/Twitch.js" ]
},
{
"matches": [ "*://www.rabb.it/*" ],
"js": [ "js/presences/Video/Rabb.it.js" ]
},
{
"matches": [ "*://www.crunchyroll.com/*" ],
"js": [ "js/presences/Anime/Crunchyroll.js" ]
}
],
"permissions": [ "http://localhost:3020/", "tabs", "storage" ],
"content_security_policy": "script-src 'self' https://*.premid.app/*; object-src 'self'",
"applications": {
"gecko": {
"id": "support@premid.app",
"strict_min_version": "52.0",
"update_url": "https://api.premid.app/firefox/updates"
}
}
"name": "PreMiD",
"author": "Timeraa & Fruxh",
"description": "__MSG_description__",
"default_locale": "en",
"version": "1.3.2.1",
"manifest_version": 2,
"web_accessible_resources": ["icon.png", "languages/*.json"],
"browser_action": {
"default_popup": "html/popup.html",
"default_icon": {
"1024": "icon.png"
}
},
"icons": {
"1024": "icon.png"
},
"background": {
"scripts": ["js/util/socket.io-2.1.1.min.js", "js/background.js"]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": [
"js/util/jquery-3.3.1.min.js",
"js/util/socketConnector.js",
"js/util/langManager.js"
],
"css": ["css/connect.css"]
},
{
"matches": ["<all_urls>"],
"js": ["js/util/jquery-3.3.1.min.js", "js/presences/iframeWitch.js"],
"all_frames": true
},
{
"matches": ["*://www.youtube.com/*"],
"js": ["js/presences/Video/YouTube.js"]
},
{
"matches": ["*://music.youtube.com/*"],
"js": ["js/presences/Music/YouTube_Music.js"]
},
{
"matches": ["*://soundcloud.com/*"],
"js": ["js/presences/Music/SoundCloud.js"]
},
{
"matches": ["*://www.netflix.com/*"],
"js": ["js/presences/Video/Netflix.js"]
},
{
"matches": ["*://www.twitch.tv/*"],
"js": ["js/presences/Video/Twitch.js"]
},
{
"matches": ["*://www.crunchyroll.com/*"],
"js": ["js/presences/Anime/Crunchyroll.js"]
}
],
"permissions": ["http://localhost:3020/", "tabs", "storage"],
"content_security_policy": "script-src 'self' https://*.premid.app/*; object-src 'self'",
"applications": {
"gecko": {
"id": "support@premid.app",
"strict_min_version": "52.0",
"update_url": "https://api.premid.app/firefox/updates"
}
}
}