mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-07 00:29:23 +00:00
Live chat interval removel, non-self return http calls to prevent crash, minor doc fix, more logs
This commit is contained in:
parent
152b9b23cd
commit
447ed6bf21
6 changed files with 19 additions and 12 deletions
2
app/src/main/assets/devportal/plugin.d.ts
vendored
2
app/src/main/assets/devportal/plugin.d.ts
vendored
|
@ -127,7 +127,7 @@ declare class PlatformVideoDetails extends PlatformVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface PlatformPostDef extends PlatformContentDef {
|
declare interface PlatformPostDef extends PlatformContentDef {
|
||||||
thumbnails: string[],
|
thumbnails: Thumbnails[],
|
||||||
images: string[],
|
images: string[],
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,5 @@ package com.futo.platformplayer.api.media.models.live
|
||||||
interface ILiveChatWindowDescriptor {
|
interface ILiveChatWindowDescriptor {
|
||||||
val url: String;
|
val url: String;
|
||||||
val removeElements: List<String>;
|
val removeElements: List<String>;
|
||||||
|
val removeElementsInterval: List<String>;
|
||||||
}
|
}
|
|
@ -8,6 +8,8 @@ import com.futo.platformplayer.api.media.models.contents.IPlatformContentDetails
|
||||||
import com.futo.platformplayer.api.media.structures.IPager
|
import com.futo.platformplayer.api.media.structures.IPager
|
||||||
import com.futo.platformplayer.states.StateApp
|
import com.futo.platformplayer.states.StateApp
|
||||||
import com.futo.platformplayer.states.StateDeveloper
|
import com.futo.platformplayer.states.StateDeveloper
|
||||||
|
import kotlinx.serialization.encodeToString
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class DevJSClient : JSClient {
|
class DevJSClient : JSClient {
|
||||||
|
@ -115,7 +117,7 @@ class DevJSClient : JSClient {
|
||||||
|
|
||||||
//Video
|
//Video
|
||||||
override fun isContentDetailsUrl(url: String): Boolean {
|
override fun isContentDetailsUrl(url: String): Boolean {
|
||||||
return StateDeveloper.instance.handleDevCall(devID, "isVideoDetailsUrl"){
|
return StateDeveloper.instance.handleDevCall(devID, "isVideoDetailsUrl(${Json.encodeToString(url)})"){
|
||||||
super.isContentDetailsUrl(url);
|
super.isContentDetailsUrl(url);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ import java.time.ZoneOffset
|
||||||
class JSLiveChatWindowDescriptor: ILiveChatWindowDescriptor {
|
class JSLiveChatWindowDescriptor: ILiveChatWindowDescriptor {
|
||||||
override val url: String;
|
override val url: String;
|
||||||
override val removeElements: List<String>;
|
override val removeElements: List<String>;
|
||||||
|
override val removeElementsInterval: List<String>;
|
||||||
|
|
||||||
constructor(config: SourcePluginConfig, obj: V8ValueObject) {
|
constructor(config: SourcePluginConfig, obj: V8ValueObject) {
|
||||||
val contextName = "LiveChatWindowDescriptor";
|
val contextName = "LiveChatWindowDescriptor";
|
||||||
|
|
||||||
url = obj.getOrThrow(config, "url", contextName);
|
url = obj.getOrThrow(config, "url", contextName);
|
||||||
removeElements = obj.getOrDefault(config, "removeElements", contextName, listOf()) ?: listOf();
|
removeElements = obj.getOrDefault(config, "removeElements", contextName, listOf()) ?: listOf();
|
||||||
|
removeElementsInterval = obj.getOrDefault(config, "removeElementsInterval", contextName, listOf()) ?: listOf();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -211,28 +211,24 @@ class PackageHttp: V8Package {
|
||||||
}
|
}
|
||||||
|
|
||||||
@V8Function
|
@V8Function
|
||||||
fun setDefaultHeaders(defaultHeaders: Map<String, String>): PackageHttpClient {
|
fun setDefaultHeaders(defaultHeaders: Map<String, String>) {
|
||||||
for(pair in defaultHeaders)
|
for(pair in defaultHeaders)
|
||||||
_defaultHeaders[pair.key] = pair.value;
|
_defaultHeaders[pair.key] = pair.value;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
@V8Function
|
@V8Function
|
||||||
fun setDoApplyCookies(apply: Boolean): PackageHttpClient {
|
fun setDoApplyCookies(apply: Boolean) {
|
||||||
if(_client is JSHttpClient)
|
if(_client is JSHttpClient)
|
||||||
_client.doApplyCookies = apply;
|
_client.doApplyCookies = apply;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
@V8Function
|
@V8Function
|
||||||
fun setDoUpdateCookies(update: Boolean): PackageHttpClient {
|
fun setDoUpdateCookies(update: Boolean) {
|
||||||
if(_client is JSHttpClient)
|
if(_client is JSHttpClient)
|
||||||
_client.doUpdateCookies = update;
|
_client.doUpdateCookies = update;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
@V8Function
|
@V8Function
|
||||||
fun setDoAllowNewCookies(allow: Boolean): PackageHttpClient {
|
fun setDoAllowNewCookies(allow: Boolean) {
|
||||||
if(_client is JSHttpClient)
|
if(_client is JSHttpClient)
|
||||||
_client.doAllowNewCookies = allow;
|
_client.doAllowNewCookies = allow;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@V8Function
|
@V8Function
|
||||||
|
|
|
@ -106,8 +106,15 @@ class LiveChatOverlay : LinearLayout {
|
||||||
override fun onPageFinished(view: WebView?, url: String?) {
|
override fun onPageFinished(view: WebView?, url: String?) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
_window?.let {
|
_window?.let {
|
||||||
|
var toRemoveJS = "";
|
||||||
for(req in it.removeElements)
|
for(req in it.removeElements)
|
||||||
view?.evaluateJavascript("document.querySelectorAll(" + _argJsonSerializer.encodeToString(req) + ").forEach(x=>x.remove());") {};
|
toRemoveJS += "document.querySelectorAll(" + _argJsonSerializer.encodeToString(req) + ").forEach(x=>x.remove());\n";
|
||||||
|
view?.evaluateJavascript(toRemoveJS) {};
|
||||||
|
var toRemoveJSInterval = "";
|
||||||
|
for(req in it.removeElementsInterval)
|
||||||
|
toRemoveJSInterval += "document.querySelectorAll(" + _argJsonSerializer.encodeToString(req) + ").forEach(x=>x.remove());\n";
|
||||||
|
//Cleanup every second as fallback
|
||||||
|
view?.evaluateJavascript("setInterval(()=>{" + toRemoveJSInterval + "}, 1000)") {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue