MCPcopy Create free account
hub / github.com/LeFroid/Viper-Browser / getAllScriptsFor

Method getAllScriptsFor

src/core/user_scripts/UserScriptManager.cpp:85–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85std::vector<QWebEngineScript> UserScriptManager::getAllScriptsFor(const QUrl &url)
86{
87 std::vector<QWebEngineScript> result;
88 if (!m_model->m_enabled)
89 return result;
90
91 QString urlStr = url.toString(QUrl::FullyEncoded);
92 for (const UserScript &script : m_model->m_scripts)
93 {
94 if (!script.m_isEnabled)
95 continue;
96
97 bool isExclude = false, isInclude = false;
98 for (const QRegularExpression &expr : script.m_excludes)
99 {
100 if (expr.match(urlStr).hasMatch())
101 {
102 isExclude = true;
103 break;
104 }
105 }
106
107 if (isExclude)
108 continue;
109
110 for (const QRegularExpression &expr : script.m_includes)
111 {
112 if (expr.match(urlStr).hasMatch())
113 {
114 isInclude = true;
115 break;
116 }
117 }
118
119 if (isInclude)
120 {
121 WebEngineScriptAdapter scriptAdapter(script);
122 result.push_back(scriptAdapter.getScript());
123 }
124 }
125 return result;
126}
127
128void UserScriptManager::installScript(const QUrl &url)
129{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected