Refactor extension to webpack
This change is the biggest in the history of the project. The entire
project has been refactored so it is built with webpack.
This involves:
- Creating webpack and npm config files.
- Fixing some bugs in the code due to the fact that webpack uses strict
mode.
- Merging some pieces of code which were shared throughout the codebase
(not exhaustive, more work should be done in this direction).
- Splitting the console_inject.js file into separate files (it had 1000+
lines).
- Adapting all the build-related files (Makefile, bash scripts, etc.)
- Changing the docs to explain the new build process.
- Changing the Zuul playbook/roles to adapt to the new build process.
Change-Id: I16476d47825461c3a318b3f1a1eddb06b2df2e89
diff --git a/src/contentScripts/communityConsole/utils.js b/src/contentScripts/communityConsole/utils.js
new file mode 100644
index 0000000..ca452b3
--- /dev/null
+++ b/src/contentScripts/communityConsole/utils.js
@@ -0,0 +1,27 @@
+export function removeChildNodes(node) {
+ while (node.firstChild) {
+ node.removeChild(node.firstChild);
+ }
+}
+
+export function getNParent(node, n) {
+ if (n <= 0) return node;
+ if (!('parentNode' in node)) return null;
+ return getNParent(node.parentNode, n - 1);
+}
+
+export function createExtBadge() {
+ var badge = document.createElement('div');
+ badge.classList.add('TWPT-badge');
+ badge.setAttribute(
+ 'title', chrome.i18n.getMessage('inject_extension_badge_helper', [
+ chrome.i18n.getMessage('appName')
+ ]));
+
+ var badgeI = document.createElement('i');
+ badgeI.classList.add('material-icon-i', 'material-icons-extended');
+ badgeI.textContent = 'repeat';
+
+ badge.append(badgeI);
+ return badge;
+}