Last active
September 13, 2023 18:30
-
-
Save Izofeu/d8b0ffc1968071bc069c0e5178dd6153 to your computer and use it in GitHub Desktop.
A poorly coded app in C++ that automatically replaces Twitter links with c.vxtwitter. Poorly updated to support X links.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
#include <windows.h> | |
#include <cstring> | |
using namespace std; | |
/* run this program using the console pauser or add your own getch, system("pause") or input loop */ | |
int main(int argc, char** argv) { | |
bool firstRun = true; | |
DWORD clipboardold; | |
while(true) | |
{ | |
if(!OpenClipboard(nullptr)) | |
{ | |
cout<<"Failed to open the clipboard."<<endl; | |
Sleep(200); | |
continue; | |
} | |
if(firstRun) | |
{ | |
FreeConsole(); | |
firstRun = false; | |
} | |
HANDLE hClipboardData = GetClipboardData(CF_TEXT); | |
if (hClipboardData == nullptr) | |
{ | |
CloseClipboard(); | |
Sleep(200); | |
continue; | |
// cout<<"Failed to get the clipboard data."<<endl; | |
// getch(); | |
// return 1; | |
} | |
char* pszText = static_cast<char*>(GlobalLock(hClipboardData)); | |
if(pszText == nullptr) | |
{ | |
cout<<"Failed to lock the clipboard data."<<endl; | |
CloseClipboard(); | |
Sleep(200); | |
continue; | |
} | |
// cout << "text: " << pszText << endl; | |
GlobalUnlock(hClipboardData); | |
string oldtext(pszText); | |
string oldtext2 = oldtext.substr(0,20); | |
string oldtext3 = oldtext.substr(0,14); | |
string tomatch = "https://twitter.com/"; | |
string tomatch2 = "https://x.com/"; | |
// cout<<"1: "<<oldtext<<endl<<"2: "<<oldtext2<<endl; | |
if(oldtext2 == tomatch) | |
{ | |
// cout<<"here"<<endl; | |
string textToCopy = "https://c.vxtwitter.com/" + oldtext.substr(20,string::npos); | |
EmptyClipboard(); | |
size_t dataSize = (textToCopy.size() + 1) * sizeof(char); | |
HGLOBAL h2ClipboardData = GlobalAlloc(GMEM_MOVEABLE, dataSize); | |
char* pClipboardData = static_cast<char*>(GlobalLock(h2ClipboardData)); | |
memcpy(pClipboardData, textToCopy.c_str(), dataSize); | |
GlobalUnlock(hClipboardData); | |
SetClipboardData(CF_TEXT, h2ClipboardData); | |
GlobalFree(h2ClipboardData); | |
} | |
else if(oldtext3 == tomatch2) | |
{ | |
string textToCopy = "https://c.vxtwitter.com/" + oldtext.substr(14,string::npos); | |
EmptyClipboard(); | |
size_t dataSize = (textToCopy.size() + 1) * sizeof(char); | |
HGLOBAL h2ClipboardData = GlobalAlloc(GMEM_MOVEABLE, dataSize); | |
char* pClipboardData = static_cast<char*>(GlobalLock(h2ClipboardData)); | |
memcpy(pClipboardData, textToCopy.c_str(), dataSize); | |
GlobalUnlock(hClipboardData); | |
SetClipboardData(CF_TEXT, h2ClipboardData); | |
GlobalFree(h2ClipboardData); | |
} | |
clipboardold = GetClipboardSequenceNumber(); | |
CloseClipboard(); | |
Sleep(200); | |
while(true) | |
{ | |
if(clipboardold != GetClipboardSequenceNumber()) | |
{ | |
break; | |
} | |
Sleep(200); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment