def _on_onload_event(self, view, frame): # Check if the URL in the main frame is the one we initially requested current_uri = self.get_main_frame().get_uri() if not is_host_and_path_same(current_uri, self._uri): # If this redirect isn't already recorded, there is something fishy in the state of our redirect tracking.. # JS navigation, probably.. temp_uri_list = self._get_ignore_redirects_list() if current_uri not in temp_uri_list\ and current_uri not in self._redirects: self._redirects.append(current_uri) # Let's see if we have any plugins that want to run at onload time.. filter_and_inject_plugins(self, frame.get_uri(), 'load')
def _on_resource_response_received(self, view, frame, resource, response): try: content_type = frame.get_data_source().get_main_resource().get_mime_type() except: content_type = '' if content_type == 'text/html': # and frame.get_parent() == None: # Wow, here comes The Content! # Well, at least there is a text/html response in the main window. # We assume that at this point, a HTML page is being delivered but its JS has not run yet # This seems like a good place to do spoofing and injectionTime:start plugins if not frame in self._js_injected_frames: if self._tab_type is 'fos': self.execute_script(FOS_SPOOF_SCRIPT) else: self.execute_script(IOS_SPOOF_SCRIPT) # This is also a good place to inject JS for any 'start' plug-ins filter_and_inject_plugins(self, frame.get_uri(), 'start') self._js_injected_frames[frame] = True self._resources.remove(resource)