-
Notifications
You must be signed in to change notification settings - Fork 629
[en]Third‐party query interfaces
When the interface is triggered (by clicking a button or a floating video bar), a window will pop up to open the URL specified in the settings. If this URL contains template parameters, they will be formatted based on the current webpage's URL.
Example url: http://example/query?url=${url}&xxx=${params.id}&yyy=${params.id2}
Example current page url: http://127.0.0.1/file.txt?id=123&id2=xxx#aa
Name | Value |
---|---|
url | http://127.0.0.1/file.txt?id=123#aa |
protocol | http: |
host | 127.0.0.1:8080 |
hostname | 127.0.0.1 |
path | /file.txt?id=123#aa |
pathname | /file.txt |
search | ?id=123 |
hash | #aa |
params | Object{id: 123, id2: xxx} |
The formated final url:
http://example/query?url=http%3A%2F%2F127.0.0.1%2Ffile.txt%3Fid%3D123%23aa&xxx=123&yyy=xxx
The value of this option is a CSS selector, which defaults to "body" but can be changed to another selector.
When the window opens, it will use this CSS selector to locate an element on the webpage and make it fill the entire screen, covering other elements. This is important because, in most cases, users only need to see the download link section.
This option consists of a list of CSS selectors, with one selector per line.
When the window opens and the corresponding webpage is loaded, you may want to hide certain unwanted elements, such as images or ads, to create a cleaner appearance.
When the interface is triggered (by clicking a button or a floating video bar), the corresponding script code will be executed, and a download list window will pop up.
If the script returns a value using the return keyword, and that value is an Object containing any of the properties files, videos, or audios, with those properties being of type Array, the values will be added to the download list window. Users can then click the download buttons in the list to download the corresponding files. If the returned value is not an Object, it will be displayed as an error message.
You can execute HTTP requests to retrieve the download address list from other servers, or use DOM manipulation to extract the download address list from the current webpage.
copy_to_clipboard(String)
Base64 = {
encode: function(String), //base64 utf8 encode
decode: function(String) //base64 utf8 decode
}
Page = {
cookie: String, //Current page cookie
user_agent: String, //Current page user agent
progress: Function(text), //This is an invokable function. when you call this function, it will update the "Loading" text.
url: String, //Current page url string
protocol: String, //Current page url.protocol
host: String, //Current page url.host
hostname: String, //Current page url.hostname
path: String, //Current page url.path
pathname: String, //Current page url.pathname
search: String, //Current page url.search
hash: String, //Current page url.hash
params: String, //Current page url.params
}
ui.alert(text,title = "",type = "information")
ui.prompt(text,title = "",default_value = "")
ui.confirm(text,title = "")
A successful return value is an Object that includes the properties files, videos, and audios, all of which must be of type Array. Even if these Arrays contain only a single entry, if an Array is empty, the corresponding category label will not be created in the download list window.
The download address values contained in the Arrays are Object objects. Please refer to the list below for the properties of these Object objects.
{
url: String, //(very important:) The download address
type: String, //(optional): the type of the file, suck as mp4, m3u8, it's important if the type is m3u8.
text: String, //(optional): The display text of the file
file_name: String, //(optional): The file name
max_connections: Number, //(optional): How many connections should the download manager establish to download this file. (Invalid for the browser builtin download manager)
header: Object //(optional): The HTTP request headers for the file, represented as a key-value object. This typically includes fields such as `referer`, `user-agent`, and `cookie`.
}
about cookie:
If you want to include cookies in the HTTP headers, in addition to using a custom string, you can simply set it to true to allow the browser to automatically detect the cookies for the corresponding URL.
For example:
{
url: "http://127.0.0.1/1.txt",
header:{
cookie: true //or, you could use the Page.cookie to get the cookie from the current web page.
}
}
videos = [
{url:"http://127.0.0.1/xxxxx",type:"mp4",text:"Test result"}
];
audios = [];
for(let i=0;i<100;++i){
Page.progress("Loading " + i + "%");
sleep(20);
}
Page.progress("Fetching...");
http = HTTP.get("https://127.0.0.1/file?url=" + encodeURIComponent(Page.url),{
headers:{
referer:"https://127.0.0.1"
}
});
if(http.status === 200)
{
json = http.JSON;
if(!json || !is_array(json.videos)){
return "Data error";
}
for(i=0;i<json.videos.length;++i){
video = json.videos[i];
videos.push({
text:video.text,
url:video.url,
header:{
referer: "https://127.0.0.1",
cookie: Page.cookie
}
})
}
}else{
//return "Data error";
}
return {videos:videos,audios:audios};
See more at: TrashScript
Files VS Videos&Audios
When the interface type is "Data Source" and the file type is "Videos & Audios," the download links for the video or audio files will not only be added to the download list dialog but will also be included in the popup list and the collector mode.
The "Trigger" specifies how the interface should be activated. If the "Video Floating Bar" option is selected, a Video Floating Bar will be automatically created when a video element is detected on the webpage. Additionally, a submenu item will be created based on the interface's name and icon, and added to the Video Floating Bar. Clicking this submenu item will trigger the interface.
If the "Create Button" option is selected, a button will be created and inserted at the specified location on the webpage when it is detected. Clicking this button will also trigger the interface.
Both options can coexist simultaneously.
The "Hosts" section contains a list of hosts, with one entry per line. Each entry can be a domain name or an IP address without a port. When the browser opens a webpage that matches any of the addresses in this list (or if an iframe on the page contains one of these addresses), a button or a Video Floating Bar will be created based on the selected Trigger options. If the "Paths" section below is not empty, the specified paths will also be matched.
The "Paths" section is a list of paths, such as /file?xx=123, with one path per line.
It can contain multiple entries, typically in the form of regular expressions. If this section is empty, no path matching will occur, and any path corresponding to the specified host will be considered valid.