add addons

This commit is contained in:
Bitl 2023-01-06 12:17:40 -07:00
parent eaecb76d7a
commit d37c43d8b0
5 changed files with 128 additions and 1 deletions

55
Asset.cs Normal file
View File

@ -0,0 +1,55 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Web;
using System.Collections.Generic;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models;
using Novetus.Core;
public class Asset : IWebProxyExtension
{
public override string Name()
{
return "Asset Redirection Extension";
}
public override bool IsValidURL(string absolutePath, string host)
{
return (absolutePath.EndsWith("/asset") || absolutePath.EndsWith("/asset/"));
}
public override async Task OnRequest(object sender, SessionEventArgs e)
{
string query = e.HttpClient.Request.RequestUri.Query;
long id;
if (!long.TryParse(NetFuncs.FindQueryString(query, "id"), out id))
{
Util.ConsolePrint(Name() + ": Redirecting " + query, 3);
e.Redirect("https://assetdelivery.roblox.com/v1/asset/" + query);
}
else
{
List<string> PathList = new List<string>((IEnumerable<string>)Directory.GetFiles(GlobalPaths.DataPath, id.ToString(), SearchOption.AllDirectories));
if (PathList.Count > 0)
{
Util.ConsolePrint(Name() + ": Local assets for " + id.ToString() + " found. Redirecting " + query, 3);
string First = PathList[0];
byte[] numArray = await Task.Run(() => File.ReadAllBytes(First));
e.Ok(numArray, (IEnumerable<HttpHeader>) new List<HttpHeader>()
{
new HttpHeader("Content-Length", ((long) numArray.Length).ToString()),
new HttpHeader("Cache-Control", "no-cache")
});
}
else
{
Util.ConsolePrint(Name() + ": No local assets for " + id.ToString() + ". Redirecting " + query, 5);
e.Redirect("https://assetdelivery.roblox.com/v1/asset/" + query);
}
}
}
}

28
StudioLaunchPage.cs Normal file
View File

@ -0,0 +1,28 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Web;
using System.Collections.Generic;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models;
using Novetus.Core;
public class StudioLaunchPage : IWebProxyExtension
{
public override string Name()
{
return "Studio Launch Page Extension";
}
public override bool IsValidURL(string absolutePath, string host)
{
return absolutePath.EndsWith("/ide/landing.aspx") || absolutePath.EndsWith("/my/places.aspx");
}
public override async Task OnRequest(object sender, SessionEventArgs e)
{
e.Ok("Welcome to Novetus Studio version " + GlobalVars.ProgramInformation.Version);
}
}

39
UploadWarnings.cs Normal file
View File

@ -0,0 +1,39 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Web;
using System.Collections.Generic;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models;
using Novetus.Core;
public class UploadWarnings : IWebProxyExtension
{
public override string Name()
{
return "Upload Dialog Warnings Extension";
}
public override bool IsValidURL(string absolutePath, string host)
{
return absolutePath.EndsWith("/uploadmedia/postimage.aspx") || absolutePath.EndsWith("/uploadmedia/uploadvideo.aspx");
}
public override async Task OnRequest(object sender, SessionEventArgs e)
{
string absPath = e.HttpClient.Request.RequestUri.AbsolutePath.ToLowerInvariant();
string type = "video";
string folder = "Videos";
if (absPath.EndsWith("/uploadmedia/postimage.aspx"))
{
type = "screenshot";
folder = "Pictures";
}
e.Ok("Your " + type + " was saved! Look in the Roblox folder in your " + folder + " folder!");
}
}

View File

@ -160,5 +160,10 @@ XCOPY "%cd%\Novetus\addons\Addon_Template.lua" "%dest%" /y
XCOPY "%cd%\Novetus\addons\Utils.lua" "%dest%" /y
XCOPY "%cd%\Novetus\addons\ShadersCompatibility.lua" "%dest%" /y
XCOPY "%cd%\Novetus\addons\ServerWhitelist.lua" "%dest%" /y
XCOPY "%cd%\Novetus\addons\core\AddonLoader.lua" "%dest%" /y
XCOPY "%cd%\Novetus\addons\novetusexts\webproxy\Asset.cs" "%dest%" /y
XCOPY "%cd%\Novetus\addons\novetusexts\webproxy\StudioLaunchPage.cs" "%dest%" /y
XCOPY "%cd%\Novetus\addons\novetusexts\webproxy\UploadWarnings.cs" "%dest%" /y
if %debug%==1 pause

View File

@ -9,5 +9,5 @@ ExtendedVersionEditChangelog=True
//ExtendedVersionTemplate=%version% v11.2022.%extended-revision%%lite%
ExtendedVersionTemplate=%version% Snapshot v22.%build%.%revision%.%extended-revision%
ExtendedVersionRevision=1
InitialBootup=False
InitialBootup=True
IsLite=False