diff --git a/lib/plugins/validators/sync/06_autoplay.js b/lib/plugins/validators/sync/06_autoplay.js index 2733bf16a..2c8880c9d 100644 --- a/lib/plugins/validators/sync/06_autoplay.js +++ b/lib/plugins/validators/sync/06_autoplay.js @@ -1,10 +1,7 @@ -import * as _ from 'underscore'; - export default { prepareLink: function(link) { - if (link.href && link.type && link.type.indexOf('video/') > -1 && link.rel.indexOf(CONFIG.R.autoplay) > -1) { // Remove "autoplay" from html5 videos. link.rel.splice(link.rel.indexOf(CONFIG.R.autoplay), 1); @@ -29,11 +26,10 @@ export default { var play = link.autoplay; // don't need this field any longer delete link.autoplay; - if (link.href.indexOf(play) > -1 || link.rel.indexOf(CONFIG.R.autoplay) == -1) { - var stop = play.replace (/\=(\w+)/, function (p1, p2) { + var stop = play.replace(/\=(\w+)/, function (p1, p2) { var antonyms = { '1': '0', '0': '1', @@ -45,8 +41,8 @@ export default { return '=' + antonyms[p2]; }); - var rels = _.clone(link.rel); - var new_link = _.extend({}, link); + var rels = [...link.rel]; + var new_link = Object.assign({}, link); new_link.rel = rels; // deep copy diff --git a/plugins/custom/og-image-rel-image.js b/plugins/custom/og-image-rel-image.js index ede29456c..d300de450 100644 --- a/plugins/custom/og-image-rel-image.js +++ b/plugins/custom/og-image-rel-image.js @@ -1,6 +1,4 @@ -import * as _ from "underscore"; - -var rel = [CONFIG.R.image, CONFIG.R.og]; +const rel = [CONFIG.R.image, CONFIG.R.og]; function getImageLinks(image) { return [{ @@ -24,7 +22,7 @@ export default { if (og.image instanceof Array) { - return _.flatten(og.image.map(getImageLinks)); + return og.image.map(getImageLinks).flat(); } else if (og.image) { diff --git a/plugins/domains/itunes.apple.com/apple.music.js b/plugins/domains/itunes.apple.com/apple.music.js index e129d6f31..7fd84ab8a 100644 --- a/plugins/domains/itunes.apple.com/apple.music.js +++ b/plugins/domains/itunes.apple.com/apple.music.js @@ -1,5 +1,4 @@ import * as URL from 'url'; -import * as _ from 'underscore'; export default { @@ -27,7 +26,7 @@ export default { var at = null; if (options.redirectsHistory) { - var original_url = _.find(options.redirectsHistory, function(u) { + var original_url = options.redirectsHistory.find(function(u) { return u.indexOf('at=') > -1; }); var query = original_url && URL.parse(original_url, true).query; diff --git a/plugins/links/hosted/promo.js b/plugins/links/hosted/promo.js index c21459af7..446ad4249 100644 --- a/plugins/links/hosted/promo.js +++ b/plugins/links/hosted/promo.js @@ -1,5 +1,3 @@ -import * as _ from 'underscore'; - export default { provides: 'self', @@ -19,7 +17,7 @@ export default { promoUri = 'http:' + promoUri; } - var options2 = _.extend({}, options, {debug: false, mixAllWithDomainPlugin: false}); + var options2 = {...options, ...{debug: false, mixAllWithDomainPlugin: false}}; delete options2.promoUri; delete options2.jar; @@ -51,7 +49,7 @@ export default { var hasGoodLinks = false; var links = promo.links.filter(function(link) { - var match = _.intersection(link.rel, CONFIG.PROMO_RELS); + var match = CONFIG.PROMO_RELS.filter(rel => link.rel.indexOf(rel) > -1); if (match.length > 1 || (match.length > 0 && match.indexOf(CONFIG.R.thumbnail) === -1)) { // Detect if has something except thumbnail. hasGoodLinks = true; @@ -79,7 +77,7 @@ export default { delete link[attr]; } }); - if (!_.isEmpty(m)) { + if (Object.keys(m).length > 0) { link.media = m; } if (typeof __promoUri === "string") { diff --git a/plugins/links/og-video.js b/plugins/links/og-video.js index f2a798b41..91f6063ef 100644 --- a/plugins/links/og-video.js +++ b/plugins/links/og-video.js @@ -1,4 +1,3 @@ -import * as _ from "underscore"; import utils from './utils.js'; function getVideoLinks(video, whitelistRecord) { @@ -57,12 +56,13 @@ export default { if (og.video instanceof Array) { - return utils.mergeMediaSize(_.flatten(og.video.map(function(video) { - return getVideoLinks(video, whitelistRecord); - }))); + return utils.mergeMediaSize( + og.video.map(function(video) { + return getVideoLinks(video, whitelistRecord); + }).flat() + ); } else if (og.video) { - return getVideoLinks(og.video, whitelistRecord); } } diff --git a/plugins/links/twitter-stream.js b/plugins/links/twitter-stream.js index b06184138..5414f3a61 100644 --- a/plugins/links/twitter-stream.js +++ b/plugins/links/twitter-stream.js @@ -1,5 +1,3 @@ -import * as _ from "underscore"; - function getStreamLinks(twitter, stream, whitelistRecord) { var player = { @@ -44,13 +42,11 @@ export default { var stream = twitter.player.stream; if (stream instanceof Array) { - - return _.flatten(stream.map(function(s) { + return stream.map(function(s) { return getStreamLinks(twitter, s, whitelistRecord); - })); + }).flat(); } else if (stream) { - return getStreamLinks(twitter, stream, whitelistRecord); } }