mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-11 09:30:46 +01:00
Merge pull request #228 from ajayyy/experimental-ajay
Invidious support fixes
This commit is contained in:
commit
d87cb77895
10 changed files with 89 additions and 38 deletions
4
SB.js
4
SB.js
|
@ -160,7 +160,9 @@ SB.defaults = {
|
||||||
"hideDeleteButtonPlayerControls": false,
|
"hideDeleteButtonPlayerControls": false,
|
||||||
"hideDiscordLaunches": 0,
|
"hideDiscordLaunches": 0,
|
||||||
"hideDiscordLink": false,
|
"hideDiscordLink": false,
|
||||||
"invidiousInstances": ["invidio.us", "invidiou.sh"]
|
"invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"],
|
||||||
|
"invidiousUpdateInfoShowCount": 0,
|
||||||
|
"autoUpvote": true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset config
|
// Reset config
|
||||||
|
|
|
@ -374,5 +374,17 @@
|
||||||
},
|
},
|
||||||
"currentInstances": {
|
"currentInstances": {
|
||||||
"message": "Current Instances:"
|
"message": "Current Instances:"
|
||||||
|
},
|
||||||
|
"enableAutoUpvote": {
|
||||||
|
"message": "Auto Upvote"
|
||||||
|
},
|
||||||
|
"whatAutoUpvote": {
|
||||||
|
"message": "With this enabled, the extension will upvote all submissions you view if you do not report them. If the notice is disabled, this will not occur."
|
||||||
|
},
|
||||||
|
"invidiousInfo1": {
|
||||||
|
"message": "Invidious (the 3rd party YouTube site) support has been added!"
|
||||||
|
},
|
||||||
|
"invidiousInfo2": {
|
||||||
|
"message": "You MUST enable it in the options for it to work."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,7 @@ chrome.tabs.onUpdated.addListener(function(tabId) {
|
||||||
}, () => void chrome.runtime.lastError ); // Suppress error on Firefox
|
}, () => void chrome.runtime.lastError ); // Suppress error on Firefox
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener(async function (request, sender, callback) {
|
chrome.runtime.onMessage.addListener(function (request, sender, callback) {
|
||||||
await wait(() => SB.config !== undefined);
|
|
||||||
|
|
||||||
switch(request.message) {
|
switch(request.message) {
|
||||||
case "submitTimes":
|
case "submitTimes":
|
||||||
submitTimes(request.videoID, callback);
|
submitTimes(request.videoID, callback);
|
||||||
|
@ -65,6 +63,8 @@ chrome.runtime.onMessage.addListener(async function (request, sender, callback)
|
||||||
|
|
||||||
//add help page on install
|
//add help page on install
|
||||||
chrome.runtime.onInstalled.addListener(function (object) {
|
chrome.runtime.onInstalled.addListener(function (object) {
|
||||||
|
// This let's the config sync to run fully before checking.
|
||||||
|
// This is required on Firefox
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
const userID = SB.config.userID;
|
const userID = SB.config.userID;
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ chrome.runtime.onInstalled.addListener(function (object) {
|
||||||
const newUserID = generateUserID();
|
const newUserID = generateUserID();
|
||||||
//save this UUID
|
//save this UUID
|
||||||
SB.config.userID = newUserID;
|
SB.config.userID = newUserID;
|
||||||
|
|
||||||
|
//TODO: Remove when invidious support is old
|
||||||
|
// Don't show this to new users
|
||||||
|
SB.config.invidiousUpdateInfoShowCount = 6;
|
||||||
}
|
}
|
||||||
}, 1500);
|
}, 1500);
|
||||||
});
|
});
|
||||||
|
@ -159,7 +163,8 @@ function submitVote(type, UUID, callback) {
|
||||||
statusCode: xmlhttp.status
|
statusCode: xmlhttp.status
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitTimes(videoID, callback) {
|
async function submitTimes(videoID, callback) {
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.sponsorSkipNotice {
|
.sponsorSkipNotice {
|
||||||
min-width: 300px;
|
min-width: 350px;
|
||||||
background-color: rgba(28, 28, 28, 0.9);
|
background-color: rgba(28, 28, 28, 0.9);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
|
|
10
content.js
10
content.js
|
@ -556,8 +556,16 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||||
//send out the message saying that a sponsor message was skipped
|
//send out the message saying that a sponsor message was skipped
|
||||||
if (!SB.config.dontShowNotice) {
|
if (!SB.config.dontShowNotice) {
|
||||||
let skipNotice = new SkipNotice(this, currentUUID, SB.config.disableAutoSkip);
|
let skipNotice = new SkipNotice(this, currentUUID, SB.config.disableAutoSkip);
|
||||||
|
|
||||||
|
//TODO: Remove this when Invidious support is old
|
||||||
|
if (SB.config.invidiousUpdateInfoShowCount < 5) {
|
||||||
|
skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("invidiousInfo1"), chrome.i18n.getMessage("invidiousInfo2"));
|
||||||
|
|
||||||
|
SB.config.invidiousUpdateInfoShowCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
//auto-upvote this sponsor
|
//auto-upvote this sponsor
|
||||||
if (SB.config.trackViewCount && !SB.config.disableAutoSkip) {
|
if (SB.config.trackViewCount && !SB.config.disableAutoSkip && SB.config.autoUpvote) {
|
||||||
vote(1, currentUUID, null);
|
vote(1, currentUUID, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,12 @@
|
||||||
Come contribute, make some suggestions and help out in the Discord: <a href="https://discord.gg/QnmVMpU">https://discord.gg/QnmVMpU</a>
|
Come contribute, make some suggestions and help out in the Discord: <a href="https://discord.gg/QnmVMpU">https://discord.gg/QnmVMpU</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<a class="bigText" href="/options/options.html">Enable Invidious Support</a>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Invidious is a third-party YouTube viewer. SponsorBlock now supports invidious along with YouTube. Please visit the options page to make sure everything is how you want it to be.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h1>How skipping works</h1>
|
<h1>How skipping works</h1>
|
||||||
|
|
||||||
<p class="projectPreview">
|
<p class="projectPreview">
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
:not(.hljs-keyword):not(.hljs-comment):not(.hljs-number):not(.hljs-string):not(pre):not(code) {
|
.bigText {
|
||||||
|
font-size: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +126,7 @@ a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
p,li {
|
p,li,a {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-size: 20;
|
font-size: 20;
|
||||||
color: #c4c4c4;
|
color: #c4c4c4;
|
||||||
|
|
|
@ -185,6 +185,23 @@
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<div option-type="toggle" sync-option="autoUpvote">
|
||||||
|
<label class="switch-container" label-name="__MSG_enableAutoUpvote__">
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" checked>
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div class="small-description">__MSG_whatAutoUpvote__</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<div option-type="toggle" sync-option="trackViewCount">
|
<div option-type="toggle" sync-option="trackViewCount">
|
||||||
<label class="switch-container" label-name="__MSG_enableViewTracking__">
|
<label class="switch-container" label-name="__MSG_enableViewTracking__">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev": "web-ext run",
|
"dev": "web-ext run --start-url https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm",
|
||||||
"build": "web-ext build --overwrite-dest -i \"*(package-lock.json|README.md|package.json|config.js.example|firefox_manifest-extra.json|manifest.json.original|ignored|crowdin.yml)\""
|
"build": "web-ext build --overwrite-dest -i \"*(package-lock.json|README.md|package.json|config.js.example|firefox_manifest-extra.json|manifest.json.original|ignored|crowdin.yml)\""
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
3
popup.js
3
popup.js
|
@ -231,7 +231,6 @@ async function runThePopup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//load video times for this video
|
//load video times for this video
|
||||||
setTimeout(()=> console.log( SB.config.sponsorTimes.set), 200 )
|
|
||||||
let sponsorTimesStorage = SB.config.sponsorTimes.get(currentVideoID);
|
let sponsorTimesStorage = SB.config.sponsorTimes.get(currentVideoID);
|
||||||
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
|
||||||
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
|
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
|
||||||
|
@ -919,10 +918,8 @@ async function runThePopup() {
|
||||||
type: type,
|
type: type,
|
||||||
UUID: UUID
|
UUID: UUID
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
console.log(response)
|
|
||||||
if (response != undefined) {
|
if (response != undefined) {
|
||||||
//see if it was a success or failure
|
//see if it was a success or failure
|
||||||
console.log(response)
|
|
||||||
if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
|
if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
|
||||||
//success (treat rate limits as a success)
|
//success (treat rate limits as a success)
|
||||||
addVoteMessage(chrome.i18n.getMessage("voted"), UUID)
|
addVoteMessage(chrome.i18n.getMessage("voted"), UUID)
|
||||||
|
|
Loading…
Reference in a new issue