Skip to content

Commit

Permalink
fix: #21, do not load inline.js on pages that may break.
Browse files Browse the repository at this point in the history
Signed-off-by: svrnm <neumanns@cisco.com>
  • Loading branch information
svrnm committed Sep 2, 2022
1 parent bc8debf commit cabf605
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
# npx lint-staged
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "DemoMonkey",
"description": "Custom demo, every demo: Turn your standard demo into a tailored experience for your customers in minutes.",
"version": "8.0.1",
"version": "8.0.2",
"author": "Severin Neumann <severin.neumann@altmuehlnet.de>",
"homepage_url": "https://github.com/svrnm/DemoMonkey/",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"highlight.js": "^11.3.1",
"ini": "^2.0.0",
"js-base64": "^3.7.2",
"json5": "^2.2.0",
"json5": "^2.2.1",
"jszip": "^3.7.1",
"lodash.omit": "^4.5.0",
"marked": "^4.0.8",
Expand Down
22 changes: 14 additions & 8 deletions src/monkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,20 @@ try {
hookIntoHyperGraph: settings.isFeatureEnabled('hookIntoHyperGraph')
}

const inlineConfigScriptTag = scope.document.createElement('script')
inlineConfigScriptTag.innerHTML = 'window.demoMonkeyConfig = ' + JSON.stringify(inlineConfig)
scope.document.head.append(inlineConfigScriptTag)

const inlineScriptTag = scope.document.createElement('script')
inlineScriptTag.setAttribute('id', 'demo-monkey-inline-script')
inlineScriptTag.src = scope.chrome.extension.getURL('js/inline.js')
scope.document.head.append(inlineScriptTag)
if (inlineConfig.hookIntoAjax || inlineConfig.hookIntoHyperGraph) {
if (!['miro.com'].includes(scope.location.host)) {
const inlineConfigScriptTag = scope.document.createElement('script')
inlineConfigScriptTag.innerHTML = 'window.demoMonkeyConfig = ' + JSON.stringify(inlineConfig)
scope.document.head.append(inlineConfigScriptTag)

const inlineScriptTag = scope.document.createElement('script')
inlineScriptTag.setAttribute('id', 'demo-monkey-inline-script')
inlineScriptTag.src = scope.chrome.extension.getURL('js/inline.js')
scope.document.head.append(inlineScriptTag)
} else {
logger('warn', `inline.js not loaded, because ${scope.location.host} may break, see https://github.com/svrnm/DemoMonkey/issues/21`).write()
}
}

// We don't use the redux store, since below we restart demo monkey
// every time the store is updated, which would lead to a loop.
Expand Down

0 comments on commit cabf605

Please sign in to comment.