1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Update contentscript to use ES6 destructuring, const, let

This commit is contained in:
Whymarrh Whitby 2019-02-12 10:31:09 -03:30
parent 969cf73fae
commit 3c915b0d7f

View File

@ -7,7 +7,7 @@ const PongStream = require('ping-pong-stream/pong')
const ObjectMultiplex = require('obj-multiplex') const ObjectMultiplex = require('obj-multiplex')
const extension = require('extensionizer') const extension = require('extensionizer')
const PortStream = require('extension-port-stream') const PortStream = require('extension-port-stream')
const TransformStream = require('stream').Transform const {Transform: TransformStream} = require('stream')
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString() const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString()
const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n' const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n'
@ -247,7 +247,7 @@ function suffixCheck () {
* @returns {boolean} {@code true} if the documentElement is an html node or if none exists * @returns {boolean} {@code true} if the documentElement is an html node or if none exists
*/ */
function documentElementCheck () { function documentElementCheck () {
var documentElement = document.documentElement.nodeName const documentElement = document.documentElement.nodeName
if (documentElement) { if (documentElement) {
return documentElement.toLowerCase() === 'html' return documentElement.toLowerCase() === 'html'
} }
@ -260,7 +260,7 @@ function documentElementCheck () {
* @returns {boolean} {@code true} if the current domain is blacklisted * @returns {boolean} {@code true} if the current domain is blacklisted
*/ */
function blacklistedDomainCheck () { function blacklistedDomainCheck () {
var blacklistedDomains = [ const blacklistedDomains = [
'uscourts.gov', 'uscourts.gov',
'dropbox.com', 'dropbox.com',
'webbyawards.com', 'webbyawards.com',
@ -271,8 +271,8 @@ function blacklistedDomainCheck () {
'ani.gamer.com.tw', 'ani.gamer.com.tw',
'blueskybooking.com', 'blueskybooking.com',
] ]
var currentUrl = window.location.href const currentUrl = window.location.href
var currentRegex let currentRegex
for (let i = 0; i < blacklistedDomains.length; i++) { for (let i = 0; i < blacklistedDomains.length; i++) {
const blacklistedDomain = blacklistedDomains[i].replace('.', '\\.') const blacklistedDomain = blacklistedDomains[i].replace('.', '\\.')
currentRegex = new RegExp(`(?:https?:\\/\\/)(?:(?!${blacklistedDomain}).)*$`) currentRegex = new RegExp(`(?:https?:\\/\\/)(?:(?!${blacklistedDomain}).)*$`)