forked from haga-rak/fluxzy.core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (31 loc) · 1.23 KB
/
Program.cs
File metadata and controls
38 lines (31 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Fluxzy;
using Fluxzy.Rules.Actions.HighLevelActions;
using Fluxzy.Rules.Filters.RequestFilters;
namespace Samples.No009.InjectCodeSnippet
{
internal class Program
{
/// <summary>
/// Inject a code snippet into traversing html content
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
static async Task Main(string[] args)
{
var fluxzySetting = FluxzySetting.CreateDefault();
fluxzySetting.ConfigureRule()
// When the content type is text/html
.When(new RequestHeaderFilter("text/html", "content-type"))
// Inject the following html tag into the head tag
.Do(new InjectHtmlTagAction()
{
HtmlContent = "<style>body { background-color: red !important; }</style>",
Tag = "head", // we insert on tag header to execute the snippet early
});
await using var proxy = new Proxy(fluxzySetting);
proxy.Run();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
}