From fdd2ad61c3e1778587fe5829eaed8e33df296461 Mon Sep 17 00:00:00 2001 From: Nicolas Rosset Date: Fri, 2 Apr 2021 18:11:06 +0200 Subject: [PATCH 1/2] Accept direct Soundcloud URL instead of data from API to share Soundcloud tracks --- tarteaucitron.services.js | 67 +++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index d03060e..a483bd4 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1235,7 +1235,7 @@ tarteaucitron.services.stonly = { window.StonlyWidget || ((window.w = window.StonlyWidget = function() { window.w._api ? window.w._api.apply(window.w, arguments) : window.w.queue.push(arguments) }).queue = []); - + tarteaucitron.addScript('https://stonly.com/js/widget/v2/stonly-widget.js?v=' + Date.now()); } }; @@ -1885,7 +1885,7 @@ tarteaucitron.services.recaptcha = { } else { tarteaucitron.addScript('https://www.google.com/recaptcha/api.js?onload=tacRecaptchaOnLoad&render=' + tarteaucitron.user.recaptchaapi); } - + }, "fallback": function () { "use strict"; @@ -2312,37 +2312,42 @@ tarteaucitron.services.soundcloud = { js: function () { "use strict"; tarteaucitron.fallback(['soundcloud_player'], function (x) { - var player_height = x.getAttribute('data-height'), - frame_height = 'height="' + player_height + '" ', - playable_id = x.getAttribute('data-playable-id'), - playable_type = x.getAttribute('data-playable-type'), - color = x.getAttribute('data-color'), - autoplay = x.getAttribute('data-auto-play'), - hideRelated = x.getAttribute('data-hide-related'), - showComments = x.getAttribute('data-show-comments'), - showUser = x.getAttribute('data-show-user'), - showReposts = x.getAttribute('data-show-reposts'), - showTeaser = x.getAttribute('data-show-teaser'), - visual = x.getAttribute('data-visual'), - artwork = x.getAttribute('data-artwork'); + var player_height = x.getAttribute('data-height'), + frame_height = 'height="' + player_height + '" ', + playable_id = x.getAttribute('data-playable-id'), + playable_type = x.getAttribute('data-playable-type'), + data_playable_url = x.getAttribute('data-playable-url'), + color = x.getAttribute('data-color'), + autoplay = x.getAttribute('data-auto-play'), + hideRelated = x.getAttribute('data-hide-related'), + showComments = x.getAttribute('data-show-comments'), + showUser = x.getAttribute('data-show-user'), + showReposts = x.getAttribute('data-show-reposts'), + showTeaser = x.getAttribute('data-show-teaser'), + visual = x.getAttribute('data-visual'), + artwork = x.getAttribute('data-artwork'); var allowAutoplay = autoplay === 'true' ? 'allow="autoplay"' : ''; - if (playable_id === undefined) { + if (playable_id === undefined && data_playable_url === undefined) { return ""; } + // Allow to embed from API results (playable_type + playable_id) var qs = '?url=https%3A//api.soundcloud.com/' + playable_type + '/' + playable_id; - if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; - if (color && color.length > 0) qs += '&color=' + color.replace('#', '%23'); - if (autoplay && autoplay.length > 0) qs += '&auto_play=' + autoplay; - if (showComments && showComments.length > 0) qs += '&show_comments=' + showComments; - if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; - if (showUser && showUser.length > 0) qs += '&show_user=' + showUser; - if (showReposts && showReposts.length > 0) qs += '&show_reposts=' + showReposts; - if (showTeaser && showTeaser.length > 0) qs += '&show_teaser=' + showTeaser; - if (visual && visual.length > 0) qs += '&visual=' + visual; - if (artwork && artwork.length > 0) qs += '&show_artwork=' + artwork; + // Or from raw URL from Soundcloud website + if (data_playable_url && data_playable_url.length >0) qs = '?url=' + escape(data_playable_url); + + if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; + if (color && color.length > 0) qs += '&color=' + color.replace('#', '%23'); + if (autoplay && autoplay.length > 0) qs += '&auto_play=' + autoplay; + if (showComments && showComments.length > 0) qs += '&show_comments=' + showComments; + if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; + if (showUser && showUser.length > 0) qs += '&show_user=' + showUser; + if (showReposts && showReposts.length > 0) qs += '&show_reposts=' + showReposts; + if (showTeaser && showTeaser.length > 0) qs += '&show_teaser=' + showTeaser; + if (visual && visual.length > 0) qs += '&visual=' + visual; + if (artwork && artwork.length > 0) qs += '&show_artwork=' + artwork; return ''; }); @@ -3039,7 +3044,7 @@ tarteaucitron.services.atinternetoptin = { "js": function () { "use strict"; tarteaucitron.launch['atinternetoptout'] = false; - + setTimeout(function() { tarteaucitron.userInterface.respond(document.getElementById('atinternetAllowed'), true); tarteaucitron.userInterface.respond(document.getElementById('atinternetoptoutDenied'), false); @@ -3256,7 +3261,7 @@ tarteaucitron.services.linkedininsighttag = { window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; window._linkedin_data_partner_ids.push(tarteaucitron.user.linkedininsighttag); } - + tarteaucitron.addScript('https://snap.licdn.com/li.lms-analytics/insight.min.js'); } }; @@ -3529,8 +3534,8 @@ tarteaucitron.services.matomo = { }, 100) } }; - - + + tarteaucitron.services.matomohightrack = { "key": "matomohightrack", "type": "analytic", @@ -3851,7 +3856,7 @@ tarteaucitron.services.userlike = { tarteaucitron.addScript('//userlike-cdn-widgets.s3-eu-west-1.amazonaws.com/' + tarteaucitron.user.userlikeKey); } }; - + // adobeanalytics tarteaucitron.services.adobeanalytics = { "key": "adobeanalytics", From f9f636ce97e414c78a63e2feeed182e196cda688 Mon Sep 17 00:00:00 2001 From: Nicolas Rosset Date: Fri, 2 Apr 2021 18:28:23 +0200 Subject: [PATCH 2/2] Typo --- tarteaucitron.services.js | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index a483bd4..cd5e024 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2312,42 +2312,42 @@ tarteaucitron.services.soundcloud = { js: function () { "use strict"; tarteaucitron.fallback(['soundcloud_player'], function (x) { - var player_height = x.getAttribute('data-height'), - frame_height = 'height="' + player_height + '" ', - playable_id = x.getAttribute('data-playable-id'), - playable_type = x.getAttribute('data-playable-type'), - data_playable_url = x.getAttribute('data-playable-url'), - color = x.getAttribute('data-color'), - autoplay = x.getAttribute('data-auto-play'), - hideRelated = x.getAttribute('data-hide-related'), - showComments = x.getAttribute('data-show-comments'), - showUser = x.getAttribute('data-show-user'), - showReposts = x.getAttribute('data-show-reposts'), - showTeaser = x.getAttribute('data-show-teaser'), - visual = x.getAttribute('data-visual'), - artwork = x.getAttribute('data-artwork'); + var player_height = x.getAttribute('data-height'), + frame_height = 'height="' + player_height + '" ', + playable_id = x.getAttribute('data-playable-id'), + playable_type = x.getAttribute('data-playable-type'), + playable_url = x.getAttribute('data-playable-url'), + color = x.getAttribute('data-color'), + autoplay = x.getAttribute('data-auto-play'), + hideRelated = x.getAttribute('data-hide-related'), + showComments = x.getAttribute('data-show-comments'), + showUser = x.getAttribute('data-show-user'), + showReposts = x.getAttribute('data-show-reposts'), + showTeaser = x.getAttribute('data-show-teaser'), + visual = x.getAttribute('data-visual'), + artwork = x.getAttribute('data-artwork'); var allowAutoplay = autoplay === 'true' ? 'allow="autoplay"' : ''; - if (playable_id === undefined && data_playable_url === undefined) { + if (playable_id === undefined && playable_url === undefined) { return ""; } // Allow to embed from API results (playable_type + playable_id) var qs = '?url=https%3A//api.soundcloud.com/' + playable_type + '/' + playable_id; // Or from raw URL from Soundcloud website - if (data_playable_url && data_playable_url.length >0) qs = '?url=' + escape(data_playable_url); + if (playable_url && playable_url.length >0) qs = '?url=' + escape(playable_url); - if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; - if (color && color.length > 0) qs += '&color=' + color.replace('#', '%23'); - if (autoplay && autoplay.length > 0) qs += '&auto_play=' + autoplay; - if (showComments && showComments.length > 0) qs += '&show_comments=' + showComments; - if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; - if (showUser && showUser.length > 0) qs += '&show_user=' + showUser; - if (showReposts && showReposts.length > 0) qs += '&show_reposts=' + showReposts; - if (showTeaser && showTeaser.length > 0) qs += '&show_teaser=' + showTeaser; - if (visual && visual.length > 0) qs += '&visual=' + visual; - if (artwork && artwork.length > 0) qs += '&show_artwork=' + artwork; + if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; + if (color && color.length > 0) qs += '&color=' + color.replace('#', '%23'); + if (autoplay && autoplay.length > 0) qs += '&auto_play=' + autoplay; + if (showComments && showComments.length > 0) qs += '&show_comments=' + showComments; + if (hideRelated && hideRelated.length > 0) qs += '&hide_related=' + hideRelated; + if (showUser && showUser.length > 0) qs += '&show_user=' + showUser; + if (showReposts && showReposts.length > 0) qs += '&show_reposts=' + showReposts; + if (showTeaser && showTeaser.length > 0) qs += '&show_teaser=' + showTeaser; + if (visual && visual.length > 0) qs += '&visual=' + visual; + if (artwork && artwork.length > 0) qs += '&show_artwork=' + artwork; return ''; });