Created
August 26, 2023 01:24
-
-
Save WindClan/a4061314a95957f789d05981391111cc to your computer and use it in GitHub Desktop.
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
# pip install pyqt5 | |
# pip install PyQtWebEngine | |
import sys | |
import os | |
from PyQt5.QtCore import * | |
from PyQt5.QtWidgets import * | |
from PyQt5.QtWebEngineWidgets import * | |
discordUrl = QUrl("https://discord.com/app") | |
class discord(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
self.create() | |
def downloadHandler(item): | |
item.setDownloadDirectory(os.path.expanduser(os.sep.join(["~","Downloads"]))) | |
item.accept() | |
def newView(self): | |
self.view = QWebEngineView() | |
self.view.titleChanged.connect(self.setWindowTitle) | |
self.view.iconChanged.connect(self.setWindowIcon) | |
profile = self.view.page().profile().defaultProfile() | |
profile.setPersistentStoragePath(os.path.expanduser(os.sep.join(["~",".pydiscord"]))) | |
profile.setPersistentCookiesPolicy(profile.AllowPersistentCookies) | |
profile.downloadRequested.connect(self.downloadHandler) | |
settings = profile.settings() | |
settings.setAttribute(settings.LocalStorageEnabled, True) | |
settings.setAttribute(settings.JavascriptCanPaste, True) | |
settings.setAttribute(settings.ScreenCaptureEnabled, True) | |
settings.setAttribute(settings.AllowRunningInsecureContent, True) | |
settings.setAttribute(settings.AllowWindowActivationFromJavaScript, True) | |
settings.setAttribute(settings.ScrollAnimatorEnabled, True) | |
settings.setAttribute(settings.PlaybackRequiresUserGesture, True) | |
def create(self): | |
self.newView() | |
self.setCentralWidget(self.view) | |
self.setWindowTitle("Discord") | |
self.show() | |
self.view.load(discordUrl) | |
app = QApplication(sys.argv) | |
main = discord() | |
main.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment