Strings part 1 #23

Merged
merged 11 commits into from Dec 8, 2017

Conversation

Projects
None yet
3 participants
Member

gregglind commented Dec 8, 2017

No description provided.

+truth
+debt
+cryptocurrency
+kernel panic
@pdehaan

pdehaan Dec 8, 2017

Contributor

Can somebody explain this to me? Our regex splits on \s+, so wouldn't this parse as two separate words anyways? Or should we update the regexp to split on \n?

@gregglind

gregglind Dec 8, 2017

Member

It will go on both words as single words. I decided not to be more clever than that.

addon/webextension/content-script.js
@@ -18,6 +22,8 @@ myPort.onMessage.addListener(function(m) {
}
});
+const SUPPORTURL = `https://support.mozilla.org/en-US/lookingglass`
@pdehaan

pdehaan Dec 8, 2017

Contributor

This currently 404s, but I trust will be live in time since I see how it's used below.
(nit: Also lacks a semi-colon and can probably use double quotes instead of template backticks)

@gregglind

gregglind Dec 8, 2017

Member

Good point! Fixing.

+truth
+debt
+cryptocurrency
+kernel panic
@biancadanforth

biancadanforth Dec 8, 2017

Collaborator

Is this a phrase? If so, we may need to use Array instead of splitting a string?

@gregglind

gregglind Dec 8, 2017

Member

Per above, not being fussy.

addon/webextension/manifest.json
"https://www.whatismybrowser.com/detect/*"
- ],
+ ],
@pdehaan

pdehaan Dec 8, 2017

Contributor

nit: Indenting is off here.

Not sure if ESLint is not catching these, or we don't have Circle-CI set up to run linting/tests for each PR.

addon/webextension/content-script.js
+ Can you trust your perceptions?
+ You chose this... a reminder of the forces at work in your world.
+ If you no longer wish to peer through the looking glass, you can
+ <br/><a href="${SUPPORTURL}" target="_blank">
@pdehaan

pdehaan Dec 8, 2017

Contributor

Re: target="_blank", not sure if we want to add rel="noopener noreferrer", per https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/

@@ -12,7 +12,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "LegacyExtensionsUtils",
const prefs = Services.prefs;
// our pref, set it with default false, if it's not there.
-const PREFNAME = "browser.display.truth";
+const PREFNAME = "extensions.pug.lookingglass";
@biancadanforth

biancadanforth Dec 8, 2017

Collaborator

What's "PUG"? In the soccer world I came from, that's "pick-up-group"; don't think that's it though.

@pdehaan

pdehaan Dec 8, 2017

Contributor

@gregglind

gregglind Dec 8, 2017

Member

Something game related.

-const XHEADERSITES = ['<all_urls>'];
-const XHEADERNAME = 'dontdeleteme';
-const XHEADERVALUE = '1057'
+const WORDS =
@biancadanforth

biancadanforth Dec 8, 2017

Collaborator

I'm really surprised "data" is not on this list!

addon/webextension/content-script.js
@@ -41,11 +47,12 @@ function findAndReplace(wordList) {
document.querySelectorAll(".donotdelete").forEach((node) => {
const hoverEle = document.createElement("span");
hoverEle.innerHTML = `
@pdehaan

pdehaan Dec 8, 2017

Contributor

I'm getting this locally from ESLint:

/Users/pdehaan/dev/github/mozilla/addon-wr/addon/webextension/content-script.js
   49:5   error    Unsafe assignment to innerHTML                                   no-unsanitized/property
  108:10  warning  Expected a conditional expression and instead saw an assignment  no-cond-assign
  112:11  warning  Expected a conditional expression and instead saw an assignment  no-cond-assign

✖ 3 problems (1 error, 2 warnings)

It was an .innerHTML before, so doesn't look like this is a new problem. Not sure if we just want to slap an
// eslint-disable-next-line no-unsanitized/property on the previous line to appease the ESLint gods (since we know what we're doing and accept the risks).

@@ -43,7 +43,7 @@
"path": "^0.12.7",
@pdehaan

pdehaan Dec 8, 2017

Contributor

Unrelated, but this certainly shouldn't be in devDependencies since we're probably wanting the native Node path module.
I'll take a peek at the upstream shield template, but we should ✂️ this out while we're here.


UPDATE: Upstream PR at mozilla/shield-studies-addon-template#41

addon/webextension/content-script.js
hoverEle.innerHTML = `
Can you trust your perceptions?
You chose this... a reminder of the forces at work in your world.
If you no longer wish to peer through the looking glass, you can
- <br/><a href="${SUPPORTURL}" target="_blank">
+ <br/><a href="${SUPPORTURL}" target="_blank", rel="noopener noreferrer">
@pdehaan

pdehaan Dec 8, 2017

Contributor

nit: remove comma.

Code doesn't compile as is; need to fix two syntax issues, as commented.

@@ -18,6 +22,8 @@ myPort.onMessage.addListener(function(m) {
}
});
+const SUPPORTURL = "https://support.mozilla.org/kb/lookingglass";
@biancadanforth

biancadanforth Dec 8, 2017

Collaborator

This page says "test - 12817 This article doesn't have approved content yet."; so it's not ready yet, but I assume it's the right page?

@gregglind

gregglind Dec 8, 2017

Member

that is!

addon/webextension/content-script.js
+ // skip scripts and styles
+ const tag = node.parentElement.tagName;
+ const skipped_tags = ["STYLE", "SCRIPT", "CANVAS", "SVG"]
+ if skipped_tags.includes(tag) {
@biancadanforth

biancadanforth Dec 8, 2017

Collaborator

This is invalid; need to add a parentheses around the condition statement for multiline if statements.

addon/webextension/content-script.js
}
+
+ return NodeFilter.FILTER_ACCEPT;
},
@biancadanforth

biancadanforth Dec 8, 2017

Collaborator

Missing another curly brace here; otherwise you get a parsing error on null.

This was referenced Dec 8, 2017

@gregglind gregglind merged commit 3b106a3 into master Dec 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment