| 352 | } |
| 353 | |
| 354 | void GM_Manager::scriptChanged() |
| 355 | { |
| 356 | auto *script = qobject_cast<GM_Script*>(sender()); |
| 357 | if (!script) { |
| 358 | return; |
| 359 | } |
| 360 | |
| 361 | QWebEngineScriptCollection *collection = mApp->webProfile()->scripts(); |
| 362 | const auto scripts = collection->find(script->fullName()); |
| 363 | for (const auto &script : scripts) { |
| 364 | collection->remove(script); |
| 365 | } |
| 366 | for (const auto &cmScript : std::as_const(m_contextMenuScripts)) { |
| 367 | if (cmScript->fullName() == script->fullName()) { |
| 368 | m_contextMenuScripts.removeOne(cmScript); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | if (script->startAt() == GM_Script::ContextMenu) { |
| 373 | m_contextMenuScripts.append(script); |
| 374 | } |
| 375 | else if (isEnabled()) { |
| 376 | collection->insert(script->webScript()); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | bool GM_Manager::canRunOnScheme(const QString &scheme) |
| 381 | { |