-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
136 lines (111 loc) · 4.05 KB
/
Copy pathmain.py
File metadata and controls
136 lines (111 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import tkinter as tk
from tkinter import filedialog
import os
import shutil
from tkinter import messagebox
root = tk.Tk()
selected_css = ""
selected_ccss = ""
selected_folder = ""
css_label = tk.Label(root, text="No file selected")
css_label.pack()
ccss_label = tk.Label(root, text="No file selected")
ccss_label.pack()
folder_label = tk.Label(root, text="No folder selected")
folder_label.pack()
root.title("Firefox CSS Injector")
root.geometry("400x300")
def configure_chrome():
path = os.path.join(selected_folder, "chrome")
if not os.path.exists(path):
os.makedirs(path)
print("Chrome folder created!")
else:
print("Chrome folder already exists.")
def enable_config(folder_path):
if not folder_path:
print("No folder selected!")
return
target_file = os.path.join(folder_path, "user.js")
pref_to_add = 'user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);'
already_enabled = False
if os.path.exists(target_file):
with open(target_file, "r") as f:
if pref_to_add in f.read():
already_enabled = True
# If not found, add it
if not already_enabled:
with open(target_file, "a") as f:
f.write(f"\n{pref_to_add}\n")
print("Preference added to user.js!")
else:
print("Preference already exists.")
if os.path.exists(target_file):
with open(target_file, "r") as f:
if pref_to_add in f.read():
print("Setting already found! No change needed.")
return
def import_css():
global selected_css
# This opens the "Open File" window
file_path = filedialog.askopenfilename(
initialdir="/",
title="Select your userChrome.css file",
filetypes=(("userChrome.css", "userChrome.css"), ("all files", "*.*"))
)
if file_path:
selected_css = file_path
css_label.config(text=f"Selected: {file_path}")
if file_path:
print(f"User selected: {file_path}")
def import_ccss():
global selected_ccss
# This opens the "Open File" window
file_path = filedialog.askopenfilename(
initialdir="/",
title="Select your userContent.css file",
filetypes=(("userContent.css files", "userContent.css"), ("all files", "*.*"))
)
if file_path:
selected_ccss = file_path
ccss_label.config(text=f"Selected: {file_path}")
if file_path:
print(f"User selected: {file_path}")
def select_profile():
global selected_folder
# This opens the "Open File" window
file_path = filedialog.askdirectory(initialdir=os.path.join(os.getenv('APPDATA'), "Mozilla/Firefox/Profiles"))
if file_path:
selected_folder = file_path
folder_label.config(text=f"Selected: {file_path}")
if file_path:
print(f"User selected: {file_path}")
def css_injector():
chrome_dir = os.path.join(selected_folder, "chrome")
destination_path = os.path.join(chrome_dir, "userChrome.css")
shutil.copy(selected_css, destination_path)
def ccss_injector():
chrome_dir = os.path.join(selected_folder, "chrome")
destination_path = os.path.join(chrome_dir, "userContent.css")
shutil.copy(selected_ccss, destination_path)
if css_injector:
print("Injection complete!")
messagebox.showinfo("Success", "Parfait injected successfully!\n\nPlease restart Firefox to apply changes.")
def on_click():
print("Injection started!")
enable_config(selected_folder)
configure_chrome()
css_injector()
ccss_injector()
label = tk.Label(root, text="Firefox CSS Injector", font=("Arial", 12))
label.pack(pady=10)
import_button = tk.Button(root, text="Select userChrome.css", command=import_css)
import_button.pack(pady=10)
import_button = tk.Button(root, text="Select userContent.css", command=import_ccss)
import_button.pack(pady=10)
import_button = tk.Button(root, text="Select Firefox Profile", command=select_profile)
import_button.pack(pady=10)
import_button = tk.Button(root, text="Inject", command=on_click)
import_button.pack(pady=10)
#loop
root.mainloop()