mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
export class ResourceType
|
|
{
|
|
constructor(name, preprocessor)
|
|
{
|
|
this.name = name;
|
|
this.preprocessor = preprocessor || (text => text);
|
|
}
|
|
static fromUrl(url)
|
|
{
|
|
if (url.indexOf(".css") !== -1)
|
|
{
|
|
return this.style;
|
|
}
|
|
else if (url.indexOf(".html") !== -1 || url.indexOf(".htm") !== -1)
|
|
{
|
|
return this.html;
|
|
}
|
|
else if (url.indexOf(".js") !== -1)
|
|
{
|
|
return this.script;
|
|
}
|
|
else if (url.indexOf(".txt") !== -1)
|
|
{
|
|
return this.text;
|
|
}
|
|
else
|
|
{
|
|
return this.unknown;
|
|
}
|
|
}
|
|
static get style()
|
|
{
|
|
return new ResourceType("style");
|
|
}
|
|
static get html()
|
|
{
|
|
return new ResourceType("html");
|
|
}
|
|
static get script()
|
|
{
|
|
return new ResourceType("script");
|
|
}
|
|
static get text()
|
|
{
|
|
return new ResourceType("text");
|
|
}
|
|
static get unknown()
|
|
{
|
|
return new ResourceType("unknown");
|
|
}
|
|
} |