| 173 | } |
| 174 | |
| 175 | QString UserScript::getScriptJSON() const |
| 176 | { |
| 177 | QString excludes; |
| 178 | for (const QRegularExpression &exp : m_excludes) |
| 179 | excludes.append(QString("\"%1\",").arg(exp.pattern())); |
| 180 | excludes = excludes.left(excludes.size() - 1); |
| 181 | |
| 182 | QString includes; |
| 183 | for (const QRegularExpression &exp : m_includes) |
| 184 | includes.append(QString("\"%1\",").arg(exp.pattern())); |
| 185 | includes = includes.left(includes.size() - 1); |
| 186 | |
| 187 | QString descrFix = m_description; |
| 188 | descrFix.replace("'", "\\'"); |
| 189 | QString nameFix = m_name; |
| 190 | nameFix.replace("'", "\\'"); |
| 191 | QString namespaceFix = m_namespace; |
| 192 | namespaceFix.replace("'", "\\'"); |
| 193 | QString runTime; |
| 194 | switch (m_injectionTime) |
| 195 | { |
| 196 | case ScriptInjectionTime::DocumentEnd: |
| 197 | runTime = QLatin1String("document-end"); |
| 198 | break; |
| 199 | case ScriptInjectionTime::DocumentStart: |
| 200 | runTime = QLatin1String("document-start"); |
| 201 | break; |
| 202 | case ScriptInjectionTime::DocumentIdle: |
| 203 | runTime = QLatin1String("document-idle"); |
| 204 | break; |
| 205 | } |
| 206 | return QString("{ 'description': '%1', 'excludes': [ %2 ], " |
| 207 | "'includes': [ %3 ], 'matches': [], 'name': '%4', " |
| 208 | "'namespace': '%5', 'resources': {}, 'run-at': '%6', " |
| 209 | "'version': '%7' }").arg(descrFix).arg(excludes).arg(includes).arg(nameFix).arg(namespaceFix).arg(runTime).arg(m_version); |
| 210 | } |
nothing calls this directly
no outgoing calls
no test coverage detected