aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2023-01-05 06:17:55 +0300
committerRblSb <msrblsb@gmail.com>2023-01-05 06:17:55 +0300
commitc677e281d3d74d5925e19eb0479c27f46a3c7857 (patch)
treee3e7084778b56f393d62d0167105408b231d23ca /res
parente877f070e367a7a9d93b93bf676f4afdb948356f (diff)
Add /ad command
for skipping youtube sponsored blocks
Diffstat (limited to 'res')
-rw-r--r--res/client.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/res/client.js b/res/client.js
index c63a4ef..b5be1ad 100644
--- a/res/client.js
+++ b/res/client.js
@@ -1971,6 +1971,9 @@ client_Main.prototype = {
return false;
}
switch(command) {
+ case "ad":
+ this.player.skipAd();
+ return false;
case "ban":
this.mergeRedundantArgs(args,0,2);
var name = args[0];
@@ -2146,7 +2149,8 @@ var client_Player = function(main) {
this.videoItemsEl = window.document.querySelector("#queue");
this.videoList = new VideoList();
this.main = main;
- this.players = [new client_players_Youtube(main,this)];
+ this.youtube = new client_players_Youtube(main,this);
+ this.players = [this.youtube];
this.iframePlayer = new client_players_Iframe(main,this);
this.rawPlayer = new client_players_Raw(main,this);
this.initItemButtons();
@@ -2580,6 +2584,41 @@ client_Player.prototype = {
this.skipSetRate = isLocal;
this.player.setPlaybackRate(rate);
}
+ ,skipAd: function() {
+ var _gthis = this;
+ var _this = this.videoList;
+ var item = _this.items[_this.pos];
+ if(item == null) {
+ return;
+ }
+ if(!this.youtube.isSupportedLink(item.url)) {
+ return;
+ }
+ var http = new haxe_http_HttpJs("https://sponsor.ajay.app/api/skipSegments?videoID=" + this.youtube.extractVideoId(item.url));
+ http.onData = function(text) {
+ var json;
+ try {
+ json = JSON.parse(text);
+ } catch( _g ) {
+ return;
+ }
+ var _g = 0;
+ while(_g < json.length) {
+ var block = json[_g];
+ ++_g;
+ var start = block.segment[0];
+ var end = block.segment[1];
+ var time = _gthis.getTime();
+ if(time > start - 1 && time < end) {
+ _gthis.main.send({ type : "Rewind", rewind : { time : end - time - 1}});
+ }
+ }
+ };
+ http.onError = function(msg) {
+ haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 477, className : "client.Player", methodName : "skipAd"});
+ };
+ http.request();
+ }
};
var client_Settings = function() { };
client_Settings.__name__ = true;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage