diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp
index fb293c56ae2a32cf96ee29b857fe3acb1d34fd8f..179febc48b325b29dcf53d5f18376a36ab88ce31 100644
--- a/src/core/user_script.cpp
+++ b/src/core/user_script.cpp
@@ -168,14 +168,3 @@ UserScriptData &UserScript::data() const
 }
 
 } // namespace QtWebEngineCore
-
-QT_BEGIN_NAMESPACE
-uint qHash(const QtWebEngineCore::UserScript &script, uint seed)
-{
-    if (script.isNull())
-        return 0;
-    return qHash(script.sourceCode(), seed) ^ qHash(script.name(), seed)
-           ^ (script.injectionPoint() | (script.runsOnSubFrames() << 4))
-           ^ script.worldId();
-}
-QT_END_NAMESPACE
diff --git a/src/core/user_script.h b/src/core/user_script.h
index 7aeba9131dd7b7fc56e06f7fd4fa384e9bc7c0ab..69c32c7bad2fa5b3f3b2dfffd953750f8a1bd6f3 100644
--- a/src/core/user_script.h
+++ b/src/core/user_script.h
@@ -93,8 +93,4 @@ private:
 
 } // namespace QtWebEngineCore
 
-QT_BEGIN_NAMESPACE
-uint qHash(const QtWebEngineCore::UserScript &, uint seed = 0);
-QT_END_NAMESPACE
-
 #endif // USER_SCRIPT_H
diff --git a/src/core/user_script_controller_host.cpp b/src/core/user_script_controller_host.cpp
index d57518275dd9ec23b077517ba1b2ed018bb3f2ff..a0d3f6fed96b035605d1ab98533e0bf95f2eb3da 100644
--- a/src/core/user_script_controller_host.cpp
+++ b/src/core/user_script_controller_host.cpp
@@ -116,9 +116,11 @@ void UserScriptControllerHost::addUserScript(const UserScript &script, WebConten
         return;
     // Global scripts should be dispatched to all our render processes.
     if (!adapter) {
-        m_profileWideScripts.insert(script);
-        Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
-            renderer->Send(new UserScriptController_AddScript(script.data()));
+        if (!m_profileWideScripts.contains(script)) {
+            m_profileWideScripts.append(script);
+            Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
+                renderer->Send(new UserScriptController_AddScript(script.data()));
+        }
     } else {
         content::WebContents *contents = adapter->webContents();
         ContentsScriptsMap::iterator it = m_perContentsScripts.find(contents);
@@ -126,11 +128,13 @@ void UserScriptControllerHost::addUserScript(const UserScript &script, WebConten
             // We need to keep track of RenderView/RenderViewHost changes for a given contents
             // in order to make sure the scripts stay in sync
             new WebContentsObserverHelper(this, contents);
-            it = m_perContentsScripts.insert(contents, (QSet<UserScript>() << script));
+            it = m_perContentsScripts.insert(contents, (QList<UserScript>() << script));
         } else {
-            QSet<UserScript> currentScripts = it.value();
-            currentScripts.insert(script);
-            m_perContentsScripts.insert(contents, currentScripts);
+            QList<UserScript> currentScripts = it.value();
+            if (!currentScripts.contains(script)) {
+                currentScripts.append(script);
+                m_perContentsScripts.insert(contents, currentScripts);
+            }
         }
         contents->Send(new RenderViewObserverHelper_AddScript(contents->GetRoutingID(), script.data()));
     }
@@ -151,7 +155,8 @@ bool UserScriptControllerHost::removeUserScript(const UserScript &script, WebCon
     if (script.isNull())
         return false;
     if (!adapter) {
-        QSet<UserScript>::iterator it = m_profileWideScripts.find(script);
+        QList<UserScript>::iterator it
+                = std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script);
         if (it == m_profileWideScripts.end())
             return false;
         Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
@@ -161,12 +166,12 @@ bool UserScriptControllerHost::removeUserScript(const UserScript &script, WebCon
         content::WebContents *contents = adapter->webContents();
         if (!m_perContentsScripts.contains(contents))
             return false;
-        QSet<UserScript> &set(m_perContentsScripts[contents]);
-        QSet<UserScript>::iterator it = set.find(script);
-        if (it == set.end())
+        QList<UserScript> &list(m_perContentsScripts[contents]);
+        QList<UserScript>::iterator it = std::find(list.begin(), list.end(), script);
+        if (it == list.end())
             return false;
         contents->Send(new RenderViewObserverHelper_RemoveScript(contents->GetRoutingID(), (*it).data()));
-        set.erase(it);
+        list.erase(it);
     }
     return true;
 }
@@ -184,7 +189,7 @@ void UserScriptControllerHost::clearAllScripts(WebContentsAdapter *adapter)
     }
 }
 
-const QSet<UserScript> UserScriptControllerHost::registeredScripts(WebContentsAdapter *adapter) const
+const QList<UserScript> UserScriptControllerHost::registeredScripts(WebContentsAdapter *adapter) const
 {
     if (!adapter)
         return m_profileWideScripts;
diff --git a/src/core/user_script_controller_host.h b/src/core/user_script_controller_host.h
index 49c96b33333759cbfbdadbb7ac261cc84bc547eb..3884fb3b976aa28438fe49ca7439873608fcccf5 100644
--- a/src/core/user_script_controller_host.h
+++ b/src/core/user_script_controller_host.h
@@ -64,7 +64,7 @@ public:
     bool removeUserScript(const UserScript &script, WebContentsAdapter *adapter);
     void clearAllScripts(WebContentsAdapter *adapter);
     void reserve(WebContentsAdapter *adapter, int count);
-    const QSet<UserScript> registeredScripts(WebContentsAdapter *adapter) const;
+    const QList<UserScript> registeredScripts(WebContentsAdapter *adapter) const;
 
     void renderProcessStartedWithHost(content::RenderProcessHost *renderer);
 
@@ -75,8 +75,8 @@ private:
 
     void webContentsDestroyed(content::WebContents *);
 
-    QSet<UserScript> m_profileWideScripts;
-    typedef QHash<content::WebContents *, QSet<UserScript>> ContentsScriptsMap;
+    QList<UserScript> m_profileWideScripts;
+    typedef QHash<content::WebContents *, QList<UserScript>> ContentsScriptsMap;
     ContentsScriptsMap m_perContentsScripts;
     QSet<content::RenderProcessHost *> m_observedProcesses;
     QScopedPointer<RenderProcessObserverHelper> m_renderProcessObserver;