Change user agent string
This commit is contained in:
		
							parent
							
								
									a85dafa18d
								
							
						
					
					
						commit
						040d0ff540
					
				@ -19,6 +19,8 @@ WebPage::WebPage(Translator &translator, const QString &script,
 | 
			
		||||
{
 | 
			
		||||
  profile()->setParent(this);
 | 
			
		||||
 | 
			
		||||
  changeUserAgent();
 | 
			
		||||
 | 
			
		||||
  connect(this, &WebPage::proxyAuthenticationRequired, this,
 | 
			
		||||
          &WebPage::authenticateProxy);
 | 
			
		||||
 | 
			
		||||
@ -84,6 +86,17 @@ void WebPage::addErrorToTask(const QString &text) const
 | 
			
		||||
  task_->translatorErrors.append(QString("%1: %2").arg(scriptName_, text));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void WebPage::changeUserAgent()
 | 
			
		||||
{
 | 
			
		||||
  auto userAgent = profile()->httpUserAgent().split(' ');
 | 
			
		||||
  userAgent.erase(std::remove_if(userAgent.begin(), userAgent.end(),
 | 
			
		||||
                                 [](const QString &part) {
 | 
			
		||||
                                   return part.startsWith("QtWebEngine");
 | 
			
		||||
                                 }),
 | 
			
		||||
                  userAgent.end());
 | 
			
		||||
  profile()->setHttpUserAgent(userAgent.join(' '));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void WebPage::setIgnoreSslErrors(bool ignoreSslErrors)
 | 
			
		||||
{
 | 
			
		||||
  ignoreSslErrors_ = ignoreSslErrors;
 | 
			
		||||
 | 
			
		||||
@ -42,6 +42,7 @@ private:
 | 
			
		||||
  void scheduleWebchannelInitScript();
 | 
			
		||||
  void scheduleTranslatorScript(const QString &script);
 | 
			
		||||
  void addErrorToTask(const QString &text) const;
 | 
			
		||||
  void changeUserAgent();
 | 
			
		||||
 | 
			
		||||
  Translator &translator_;
 | 
			
		||||
  QString scriptName_;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user