1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-21 21:54:07 +02:00
Files
Configuration
Core
Bridge
Controls
Handling
Notification
Other
Utils
BrowserCache.cs
BrowserUtils.cs
CommandLineArgs.cs
CommandLineArgsParser.cs
InjectedHTML.cs
NativeMethods.cs
TwoKeyDictionary.cs
WindowState.cs
WindowsUtils.cs
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
TrayIcon.Designer.cs
TrayIcon.cs
Plugins
Properties
Resources
Updates
bld
lib
subprocess
tests
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
_postbuild.bat
packages.config
TweetDuck/Core/Utils/InjectedHTML.cs

38 lines
988 B
C#

using System;
namespace TweetDuck.Core.Utils{
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);
}
}
}