-
-
Save miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775 to your computer and use it in GitHub Desktop.
| import json | |
| import sqlite3 | |
| import os | |
| DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db" | |
| def activate(): | |
| try: | |
| conn = sqlite3.connect(DB_PATH) | |
| c = conn.cursor() | |
| s = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0] | |
| dat = json.loads(s) | |
| if dat["additional"]["proStatus"] != "pro": | |
| print("Your version of Cold Turkey Blocker is not activated.") | |
| dat["additional"]["proStatus"] = "pro" | |
| print("But now it is activated.\nPlease close Cold Turkey Blocker and run again it.") | |
| c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),)) | |
| conn.commit() | |
| else: | |
| print("Looks like your copy of Cold Turkey Blocker is already activated.") | |
| print("Deactivating it now.") | |
| dat["additional"]["proStatus"] = "free" | |
| c.execute("""UPDATE settings set value = ? WHERE "key" = 'settings'""", (json.dumps(dat),)) | |
| conn.commit() | |
| except sqlite3.Error as e: | |
| print("Failed to activate", e) | |
| finally: | |
| if conn: | |
| conn.close() | |
| def main(): | |
| if os.path.exists(DB_PATH): | |
| print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.") | |
| activate() | |
| else: | |
| print("Looks like Cold Turkey Blocker is not installed.\n If it is installed then run it at least once.") | |
| if __name__ == '__main__': | |
| main() |
perfectly worked in windows but bro i am using mac one issue i am facing is how to completely close a app in background , i see in activity monitor its always running even after quit , i got toggles pro in terminal but nothing happened
press option + command + esc to force quit
Use any IDE to create the python file like VS code or antigravity.
hey all the man here helped me thanks to all wholeheartedly , as of 8th may 2026 cold turkey v4.9 it working completely fine on mac m2, when i will get money i will surely pay to this developer as a thanks
I put py main.py in the command but ":\Users\chris\AppData\Local\Programs\Python\Python314\python.exe: can't open file 'C:\Users\chris\main.py': [Errno 2] No such file or directory" just pops up
You saved in wrong location. navigate whare you have saved the file. First, save that py file in downloads and then paste this in cmd
cd /d "%userprofile%\Downloads"
Then Type py main.py It'll work
I had a lot of problems running this code but there were many indentation problems. what I did to make it work exactly:
download latest version of cold turkey from website (4.9)
download python (if you havent already)
paste this to notepad:
import json
import sqlite3
DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"
def decode(s):
data = s[5:]
return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))
def encode(s):
return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])
(ALSO: make sure to save in notepad, not as txt but under all files type in "main.py" and enter.
now use admin version of cmd, type in cd (your directory, ex C:\Users(your user)\Downloads
then type in py main.py and it should work
If the previous version is not working, try this:
Install Cold Turkey Blocker from its official website.
After installation, make sure the application is completely closed:
- Check the system tray (hidden icons on the taskbar).
- Right-click the icon and exit the application.
Open Notepad (or any text editor).
Paste the following code:
import json import sqlite3 DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db" def decode(s): data = s[5:] return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2)) def encode(s): return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s) conn = sqlite3.connect(DB_PATH) c = conn.cursor() raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0] # Handle both formats (encoded and plain JSON) if raw.startswith("CTB17"): dat = json.loads(decode(raw)) use_encode = True else: dat = json.loads(raw) use_encode = False dat["additional"]["proStatus"] = ( "free" if dat["additional"]["proStatus"] == "pro" else "pro" ) new_value = json.dumps(dat) if use_encode: new_value = encode(new_value) c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (new_value,)) conn.commit() conn.close() print("Toggled to:", dat["additional"]["proStatus"])
- Save the file as:
main.py
- Open Command Prompt as Administrator.
- Navigate to the folder where you saved the file:
cd path\to\your\folder
- Run the script:
py main.py
This is the only one working in the latest version, just download the Cold Turkey from the official website.
Final Working Script
Thank me later
import json
import sqlite3
DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"
def decode(s):
# Remove the CTB17 prefix and any whitespace/newlines
data = s[5:].strip()
# Ensure an even number of hex characters
if len(data) % 2 != 0:
data = data[:-1]
result = []
for i in range(0, len(data), 2):
hex_pair = data[i:i+2]
try:
val = int(hex_pair, 16) - 0x11
if 0 <= val <= 0x10FFFF: # Valid Unicode range
result.append(chr(val))
except ValueError:
continue # Skip invalid hex pairs
return ''.join(result)
def encode(s):
return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
# Handle both formats (encoded and plain JSON)
if raw.startswith("CTB17"):
dat = json.loads(decode(raw))
use_encode = True
else:
dat = json.loads(raw)
use_encode = False
dat["additional"]["proStatus"] = (
"free" if dat["additional"]["proStatus"] == "pro" else "pro"
)
new_value = json.dumps(dat)
if use_encode:
new_value = encode(new_value)
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (new_value,))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])
Final Working Script
Thank me later
import json import sqlite3 DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db" def decode(s): # Remove the CTB17 prefix and any whitespace/newlines data = s[5:].strip() # Ensure an even number of hex characters if len(data) % 2 != 0: data = data[:-1] result = [] for i in range(0, len(data), 2): hex_pair = data[i:i+2] try: val = int(hex_pair, 16) - 0x11 if 0 <= val <= 0x10FFFF: # Valid Unicode range result.append(chr(val)) except ValueError: continue # Skip invalid hex pairs return ''.join(result) def encode(s): return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s) conn = sqlite3.connect(DB_PATH) c = conn.cursor() raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0] # Handle both formats (encoded and plain JSON) if raw.startswith("CTB17"): dat = json.loads(decode(raw)) use_encode = True else: dat = json.loads(raw) use_encode = False dat["additional"]["proStatus"] = ( "free" if dat["additional"]["proStatus"] == "pro" else "pro" ) new_value = json.dumps(dat) if use_encode: new_value = encode(new_value) c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (new_value,)) conn.commit() conn.close() print("Toggled to:", dat["additional"]["proStatus"])
this finally works for me. I was previously getting indentation errors but now it works perfectly fine. thanks!
@ak5hiit is the GOAT frfr saving us the hassle with these indentation errors
perfectly worked in windows but bro i am using mac one issue i am facing is how to completely close a app in background , i see in activity monitor its always running even after quit , i got toggles pro in terminal but nothing happened