mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-21 03:54:07 +02:00
.github
.idea
Application
Browser
Configuration
Controls
Dialogs
Management
Plugins
Properties
Resources
Updates
Utils
bld
lib
TweetLib.Browser
TweetLib.Communication
TweetLib.Core
TweetLib.Utils
Collections
Data
InjectedString.cs
Result.cs
WindowState.cs
Globalization
IO
Serialization
Static
Lib.cs
TweetLib.Utils.csproj
TweetTest.Core
TweetTest.Utils
subprocess
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
app.config
packages.config
43 lines
835 B
C#
43 lines
835 B
C#
using System;
|
|
|
|
namespace TweetLib.Utils.Data {
|
|
public sealed class InjectedString {
|
|
public enum Position {
|
|
Before,
|
|
After
|
|
}
|
|
|
|
private readonly Position position;
|
|
private readonly string search;
|
|
private readonly string html;
|
|
|
|
public InjectedString(Position position, string search, string html) {
|
|
this.position = position;
|
|
this.search = search;
|
|
this.html = html;
|
|
}
|
|
|
|
public string InjectInto(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);
|
|
}
|
|
}
|
|
}
|