59 |
59 |
60 @param request reference to the request (QNetworkRequest) |
60 @param request reference to the request (QNetworkRequest) |
61 """ |
61 """ |
62 from .GreaseMonkeyDownloader import GreaseMonkeyDownloader |
62 from .GreaseMonkeyDownloader import GreaseMonkeyDownloader |
63 downloader = GreaseMonkeyDownloader(request, self) |
63 downloader = GreaseMonkeyDownloader(request, self) |
64 downloader.finished.connect(self.__downloaderFinished) |
64 downloader.finished.connect( |
|
65 lambda: self.__downloaderFinished(downloader)) |
65 self.__downloaders.append(downloader) |
66 self.__downloaders.append(downloader) |
66 |
67 |
67 def __downloaderFinished(self): |
68 def __downloaderFinished(self, downloader): |
68 """ |
69 """ |
69 Private slot to handle the completion of a script download. |
70 Private slot to handle the completion of a script download. |
70 """ |
71 |
71 downloader = self.sender() |
72 @param downloader reference to the downloader object |
72 if downloader is None or downloader not in self.__downloaders: |
73 @type GreaseMonkeyDownloader |
73 return |
74 """ |
74 |
75 if downloader in self.__downloaders: |
75 self.__downloaders.remove(downloader) |
76 self.__downloaders.remove(downloader) |
76 |
77 |
77 def scriptsDirectory(self): |
78 def scriptsDirectory(self): |
78 """ |
79 """ |
79 Public method to get the path of the scripts directory. |
80 Public method to get the path of the scripts directory. |
80 |
81 |
229 @param scheme scheme to check (string) |
230 @param scheme scheme to check (string) |
230 @return flag indicating, that scripts can be run (boolean) |
231 @return flag indicating, that scripts can be run (boolean) |
231 """ |
232 """ |
232 return scheme in ["http", "https", "data", "ftp"] |
233 return scheme in ["http", "https", "data", "ftp"] |
233 |
234 |
234 def pageLoadStarted(self): |
235 def pageLoadStarted(self, frame): |
235 """ |
236 """ |
236 Public slot to handle the start of loading a page. |
237 Public slot to handle the start of loading a page. |
237 """ |
238 |
238 frame = self.sender() |
239 @param frame reference to the main frame of the loading page |
239 if not frame: |
240 @type QWebFrame |
240 return |
241 """ |
241 |
|
242 urlScheme = frame.url().scheme() |
242 urlScheme = frame.url().scheme() |
243 urlString = bytes(frame.url().toEncoded()).decode() |
243 urlString = bytes(frame.url().toEncoded()).decode() |
244 |
244 |
245 if not self.canRunOnScheme(urlScheme): |
245 if not self.canRunOnScheme(urlScheme): |
246 return |
246 return |
288 """ |
288 """ |
289 Public method to allow the GreaseMonkey manager to connect to the page. |
289 Public method to allow the GreaseMonkey manager to connect to the page. |
290 |
290 |
291 @param page reference to the web page (HelpWebPage) |
291 @param page reference to the web page (HelpWebPage) |
292 """ |
292 """ |
293 page.mainFrame().javaScriptWindowObjectCleared.connect( |
293 mainFrame = page.mainFrame() |
294 self.pageLoadStarted) |
294 mainFrame.javaScriptWindowObjectCleared.connect( |
|
295 lambda: self.pageLoadStarted(mainFrame)) |
295 |
296 |
296 def createRequest(self, op, request, outgoingData=None): |
297 def createRequest(self, op, request, outgoingData=None): |
297 """ |
298 """ |
298 Public method to create a request. |
299 Public method to create a request. |
299 |
300 |