Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function load_sponsorblock(){
- const info_elem = Q('#skip_n');
- if (info_elem.innerText.length) return; // already fetched
- const hash = sha256(data.video_id).substr(0,4);
- const video_obj = Q("video");
- let url = `/https://sponsor.ajay.app/api/skipSegments/${hash}?service=YouTube&categories=%5B%22sponsor%22,%22selfpromo%22%5D`;
- fetch(url)
- .then(response => response.json())
- .then(r => {
- for (const video of r) {
- if (video.videoID != data.video_id) continue;
- info_elem.innerText = `(${video.segments.length} segments)`;
- const cat_n = video.segments.map(e=>e.category).sort()
- .reduce((acc,e) => (acc[e]=(acc[e]||0)+1, acc), {});
- info_elem.title = Object.entries(cat_n).map(e=>e.join(': ')).join(', ');
- for (const segment of video.segments) {
- const [start, stop] = segment.segment;
- if (segment.category != "sponsor" && segment.category != "selfpromo") continue;
- video_obj.addEventListener("timeupdate", function() {
- if (Q("#skip_sponsors").checked &&
- this.currentTime >= start &&
- this.currentTime < stop-1) {
- this.currentTime = stop;
- }
- });
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment