mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 12:07:11 +03:00
Bug fix for direct links
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
chrome.runtime.onMessage.addListener(
|
if(id = youtube_parser(document.URL)){ // Direct Links
|
||||||
|
SponsorsLookup(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
chrome.runtime.onMessage.addListener( // URL Changes
|
||||||
function(request, sender, sendResponse) {
|
function(request, sender, sendResponse) {
|
||||||
if (request.message === 'ytvideoid') {
|
if (request.message === 'ytvideoid') {
|
||||||
SponsorsLookup(request.id);
|
SponsorsLookup(request.id);
|
||||||
@@ -20,10 +25,16 @@ function SponsorsLookup(id) {
|
|||||||
xmlhttp.send(null);
|
xmlhttp.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SponsorCheck(Sponsors) {
|
function SponsorCheck(Sponsors) { // Video skipping
|
||||||
Sponsors.forEach(function (el, index) {
|
Sponsors.forEach(function (el, index) {
|
||||||
if ((Math.floor(v.currentTime)) == el[0]) {
|
if ((Math.floor(v.currentTime)) == el[0]) {
|
||||||
v.currentTime = el[1];
|
v.currentTime = el[1];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function youtube_parser(url) {
|
||||||
|
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
||||||
|
var match = url.match(regExp);
|
||||||
|
return (match && match[7].length == 11) ? match[7] : false;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user