(window["webpackJsonpGUI"] = window["webpackJsonpGUI"] || []).push([["addon-entry-zebra-striping"],{ /***/ "./node_modules/css-loader/index.js!./src/addons/addons/zebra-striping/userstyle.css": /*!**********************************************************************************!*\ !*** ./node_modules/css-loader!./src/addons/addons/zebra-striping/userstyle.css ***! \**********************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { exports = module.exports = __webpack_require__(/*! ../../../../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false); // imports // module exports.push([module.i, ":root {\n --zebraStriping-percent: calc(var(--zebraStriping-shadeNumber) * var(--zebraStriping-intensity) / 100);\n --zebraStriping-bright: calc(1 + var(--zebraStriping-percent));\n --zebraStriping-saturate: calc(1 - var(--zebraStriping-percent));\n --zebraStriping-filter: brightness(var(--zebraStriping-bright)) saturate(var(--zebraStriping-saturate));\n /* \"Temporary\" value, gets replaced by userscript */\n --zebraStriping-replacementGlow: url(#blocklyReplacementGlowFilter);\n}\n\n.sa-zebra-stripe {\n filter: var(--zebraStriping-filter);\n}\n\n.sa-zebra-stripe[filter*=\"#blocklyReplacementGlowFilter\"] {\n filter: var(--zebraStriping-filter) var(--zebraStriping-replacementGlow);\n}\n\n/* editor-stepping and debugger compatibility */\n/* this is pretty horrible */\n.sa-zebra-stripe[style*=\"#sa_glower_filter0\"] {\n /* !important because editor-stepping Highlighter uses inline styles */\n filter: var(--zebraStriping-filter) url(\"#sa_glower_filter0\") !important;\n}\n.sa-zebra-stripe[style*=\"#sa_glower_filter1\"] {\n filter: var(--zebraStriping-filter) url(\"#sa_glower_filter1\") !important;\n}\n", ""]); // exports /***/ }), /***/ "./src/addons/addons/zebra-striping/_runtime_entry.js": /*!************************************************************!*\ !*** ./src/addons/addons/zebra-striping/_runtime_entry.js ***! \************************************************************/ /*! exports provided: resources */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resources", function() { return resources; }); /* harmony import */ var _userscript_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./userscript.js */ "./src/addons/addons/zebra-striping/userscript.js"); /* harmony import */ var _css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! css-loader!./userstyle.css */ "./node_modules/css-loader/index.js!./src/addons/addons/zebra-striping/userstyle.css"); /* harmony import */ var _css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1__); /* generated by pull.js */ const resources = { "userscript.js": _userscript_js__WEBPACK_IMPORTED_MODULE_0__["default"], "userstyle.css": _css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1___default.a }; /***/ }), /***/ "./src/addons/addons/zebra-striping/userscript.js": /*!********************************************************!*\ !*** ./src/addons/addons/zebra-striping/userscript.js ***! \********************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = (async function ({ addon, msg, console }) { const vm = addon.tab.traps.vm; const ScratchBlocks = await addon.tab.traps.getBlockly(); const originalRender = ScratchBlocks.BlockSvg.prototype.render; ScratchBlocks.BlockSvg.prototype.render = function (opt_bubble) { // Any changes that affect block striping should bubble to the top block of the script. // The top block of the script is responsible for striping all of its children. // This way stripes are computed exactly once. if (!this.isInFlyout && !this.isShadow() && this.getParent() === null) { const stripeState = new Map(); // Conveniently getDescendants() returns blocks in an order such that each block's // parent will always come before that block (except the first block which has no // parent). for (const block of this.getDescendants()) { const parent = block.getSurroundParent(); let isStriped = false; if (parent) { if (block.isShadow()) { isStriped = !!stripeState.get(parent); } else if (parent.getColour() === block.getColour()) { isStriped = !stripeState.get(parent); } } stripeState.set(block, isStriped); const elements = [block.svgPath_]; for (const input of block.inputList) { if (input.outlinePath) { elements.push(input.outlinePath); } for (const field of input.fieldRow) { if (field.fieldGroup_) { elements.push(field.fieldGroup_); } } } for (const el of elements) { el.classList.toggle("sa-zebra-stripe", isStriped); } } } return originalRender.call(this, opt_bubble); }; if (vm.editingTarget) { vm.emitWorkspaceUpdate(); } // The replacement glow filter's ID is randomly generated and changes // when the workspace is reloaded (which includes loading the page and // seeing the project page then seeing inside). // As we need to stack the filter with the striping filter in the // userstyle, we need to use the userscript to get the filter's ID // and set a CSS variable on the document's root. while (true) { const replacementGlowEl = await addon.tab.waitForElement('filter[id*="blocklyReplacementGlowFilter"]', { markAsSeen: true, reduxEvents: ["scratch-gui/mode/SET_PLAYER", "fontsLoaded/SET_FONTS_LOADED", "scratch-gui/locales/SELECT_LOCALE"], reduxCondition: state => !state.scratchGui.mode.isPlayerOnly }); document.documentElement.style.setProperty("--zebraStriping-replacementGlow", "url(#".concat(replacementGlowEl.id, ")")); } }); /***/ }) }]); //# sourceMappingURL=addon-entry-zebra-striping.js.map