mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-14 21:16:58 +02:00
Configuration
Core
Data
Serialization
CombinedFileStream.cs
CommandLineArgs.cs
InjectedHTML.cs
ResourceLink.cs
Result.cs
TwoKeyDictionary.cs
WindowState.cs
Plugins
Properties
Resources
Updates
bld
lib
subprocess
tests
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
packages.config
38 lines
989 B
C#
38 lines
989 B
C#
using System;
|
|
|
|
namespace TweetDuck.Data{
|
|
sealed class InjectedHTML{
|
|
public enum Position{
|
|
Before, After
|
|
}
|
|
|
|
private readonly Position position;
|
|
private readonly string search;
|
|
private readonly string html;
|
|
|
|
public InjectedHTML(Position position, string search, string html){
|
|
this.position = position;
|
|
this.search = search;
|
|
this.html = html;
|
|
}
|
|
|
|
public string Inject(string targetHTML){
|
|
int index = targetHTML.IndexOf(search, StringComparison.Ordinal);
|
|
|
|
if (index == -1){
|
|
return targetHTML;
|
|
}
|
|
|
|
int cutIndex;
|
|
|
|
switch(position){
|
|
case Position.Before: cutIndex = index; break;
|
|
case Position.After: cutIndex = index+search.Length; break;
|
|
default: return targetHTML;
|
|
}
|
|
|
|
return targetHTML.Insert(cutIndex, html);
|
|
}
|
|
}
|
|
}
|