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

Method getScriptsFor

src/core/user_scripts/UserScriptManager.cpp:37–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37QString UserScriptManager::getScriptsFor(const QUrl &url, ScriptInjectionTime injectionTime, bool isMainFrame)
38{
39 if (!m_model->m_enabled)
40 return QString();
41
42 QByteArray resultBuffer;
43 QString urlStr = url.toString(QUrl::FullyEncoded);
44
45 for (const UserScript &script : m_model->m_scripts)
46 {
47 if (!script.m_isEnabled
48 || (injectionTime != script.m_injectionTime)
49 || (script.m_noSubFrames && !isMainFrame))
50 continue;
51
52 bool isExclude = false, isInclude = false;
53 for (const QRegularExpression &expr : script.m_excludes)
54 {
55 if (expr.match(urlStr).hasMatch())
56 {
57 isExclude = true;
58 break;
59 }
60 }
61
62 if (isExclude)
63 continue;
64
65 for (const QRegularExpression &expr : script.m_includes)
66 {
67 if (expr.match(urlStr).hasMatch())
68 {
69 isInclude = true;
70 break;
71 }
72 }
73
74 if (isInclude)
75 {
76 resultBuffer.append(script.m_dependencyData);
77 resultBuffer.append(QChar('\n'));
78 resultBuffer.append(script.m_scriptData);
79 }
80 }
81
82 return QString(resultBuffer);
83}
84
85std::vector<QWebEngineScript> UserScriptManager::getAllScriptsFor(const QUrl &url)
86{

Callers 1

injectUserJavaScriptMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected