Skip to content

Commit f4d64bd

Browse files
authored
Include YouTube Click to Load configuration (#224)
Since it is now up to the extension to decide which Click to Load entities are enabled, let's include the YouTube Click to Load configuration ready for when the extension enables it. Also, let's take care to pass the correct blocking action ("block-ctl-yt" or "block-ctl-fb") when unblocking the embedded content.
1 parent 76c807d commit f4d64bd

File tree

8 files changed

+454
-416
lines changed

8 files changed

+454
-416
lines changed

Sources/ContentScopeScripts/dist/contentScope.js

+65-59
Large diffs are not rendered by default.

build/android/contentScope.js

+65-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome-mv3/inject.js

+65-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome/inject.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/firefox/inject.js

+65-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/integration/contentScope.js

+65-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/windows/contentScope.js

+65-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/features/click-to-play.js

+63-61
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createCustomEvent, sendMessage, OriginalCustomEvent, originalWindowDispatchEvent } from '../utils.js'
22
import {
3-
logoImg, loadingImages, closeIcon, blockedFBLogo, ddgFont, ddgFontBold
4-
// blockedYTVideo, videoPlayDark, videoPlayLight // For YT CTL
3+
logoImg, loadingImages, closeIcon, blockedFBLogo, ddgFont, ddgFontBold,
4+
blockedYTVideo, videoPlayDark, videoPlayLight
55
} from '../assets/ctl-assets.js'
66

77
let devMode = false
@@ -969,64 +969,64 @@ const config = {
969969
}
970970
}
971971
}
972+
},
973+
Youtube: {
974+
elementData: {
975+
'YouTube embedded video': {
976+
selectors: [
977+
"iframe[src*='://youtube.com/embed']",
978+
"iframe[src*='://youtube-nocookie.com/embed']",
979+
"iframe[src*='://www.youtube.com/embed']",
980+
"iframe[src*='://www.youtube-nocookie.com/embed']",
981+
"iframe[data-src*='://youtube.com/embed']",
982+
"iframe[data-src*='://youtube-nocookie.com/embed']",
983+
"iframe[data-src*='://www.youtube.com/embed']",
984+
"iframe[data-src*='://www.youtube-nocookie.com/embed']"
985+
],
986+
replaceSettings: {
987+
type: 'youtube-video',
988+
buttonText: 'Unblock video',
989+
infoTitle: 'DuckDuckGo blocked this YouTube video to prevent Google from tracking you',
990+
infoText: 'We blocked Google (which owns YouTube) from tracking you when the page loaded. If you unblock this video, Google will know your activity.',
991+
simpleInfoText: 'We blocked Google (which owns YouTube) from tracking you when the page loaded. If you unblock this video, Google will know your activity.',
992+
previewToggleText: 'Previews disabled for additional privacy',
993+
placeholder: {
994+
previewToggleEnabledText: 'Previews enabled',
995+
previewInfoText: 'Turn previews off for additional privacy from DuckDuckGo.',
996+
videoPlayIcon: {
997+
lightMode: videoPlayLight,
998+
darkMode: videoPlayDark
999+
}
1000+
}
1001+
},
1002+
clickAction: {
1003+
type: 'youtube-video'
1004+
}
1005+
},
1006+
'YouTube embedded subscription button': {
1007+
selectors: [
1008+
"iframe[src*='://youtube.com/subscribe_embed']",
1009+
"iframe[src*='://youtube-nocookie.com/subscribe_embed']",
1010+
"iframe[src*='://www.youtube.com/subscribe_embed']",
1011+
"iframe[src*='://www.youtube-nocookie.com/subscribe_embed']",
1012+
"iframe[data-src*='://youtube.com/subscribe_embed']",
1013+
"iframe[data-src*='://youtube-nocookie.com/subscribe_embed']",
1014+
"iframe[data-src*='://www.youtube.com/subscribe_embed']",
1015+
"iframe[data-src*='://www.youtube-nocookie.com/subscribe_embed']"
1016+
],
1017+
replaceSettings: {
1018+
type: 'blank'
1019+
}
1020+
}
1021+
},
1022+
informationalModal: {
1023+
icon: blockedYTVideo,
1024+
messageTitle: 'Enable all YouTube previews?',
1025+
messageBody: 'Showing previews will allow Google (which owns YouTube) to see some of your device’s information, but is still more private than playing the video.',
1026+
confirmButtonText: 'Enable All Previews',
1027+
rejectButtonText: 'No Thanks'
1028+
}
9721029
}
973-
// Youtube: { // Config for YT CTL
974-
// elementData: {
975-
// 'YouTube embedded video': {
976-
// selectors: [
977-
// "iframe[src*='://youtube.com/embed']",
978-
// "iframe[src*='://youtube-nocookie.com/embed']",
979-
// "iframe[src*='://www.youtube.com/embed']",
980-
// "iframe[src*='://www.youtube-nocookie.com/embed']",
981-
// "iframe[data-src*='://youtube.com/embed']",
982-
// "iframe[data-src*='://youtube-nocookie.com/embed']",
983-
// "iframe[data-src*='://www.youtube.com/embed']",
984-
// "iframe[data-src*='://www.youtube-nocookie.com/embed']"
985-
// ],
986-
// replaceSettings: {
987-
// type: 'youtube-video',
988-
// buttonText: 'Unblock video',
989-
// infoTitle: 'DuckDuckGo blocked this YouTube video to prevent Google from tracking you',
990-
// infoText: 'We blocked Google (which owns YouTube) from tracking you when the page loaded. If you unblock this video, Google will know your activity.',
991-
// simpleInfoText: 'We blocked Google (which owns YouTube) from tracking you when the page loaded. If you unblock this video, Google will know your activity.',
992-
// previewToggleText: 'Previews disabled for additional privacy',
993-
// placeholder: {
994-
// previewToggleEnabledText: 'Previews enabled',
995-
// previewInfoText: 'Turn previews off for additional privacy from DuckDuckGo.',
996-
// videoPlayIcon: {
997-
// lightMode: videoPlayLight,
998-
// darkMode: videoPlayDark
999-
// }
1000-
// }
1001-
// },
1002-
// clickAction: {
1003-
// type: 'youtube-video'
1004-
// }
1005-
// },
1006-
// 'YouTube embedded subscription button': {
1007-
// selectors: [
1008-
// "iframe[src*='://youtube.com/subscribe_embed']",
1009-
// "iframe[src*='://youtube-nocookie.com/subscribe_embed']",
1010-
// "iframe[src*='://www.youtube.com/subscribe_embed']",
1011-
// "iframe[src*='://www.youtube-nocookie.com/subscribe_embed']",
1012-
// "iframe[data-src*='://youtube.com/subscribe_embed']",
1013-
// "iframe[data-src*='://youtube-nocookie.com/subscribe_embed']",
1014-
// "iframe[data-src*='://www.youtube.com/subscribe_embed']",
1015-
// "iframe[data-src*='://www.youtube-nocookie.com/subscribe_embed']"
1016-
// ],
1017-
// replaceSettings: {
1018-
// type: 'blank'
1019-
// }
1020-
// }
1021-
// },
1022-
// informationalModal: {
1023-
// icon: blockedYTVideo,
1024-
// messageTitle: 'Enable all YouTube previews?',
1025-
// messageBody: 'Showing previews will allow Google (which owns YouTube) to see some of your device’s information, but is still more private than playing the video.',
1026-
// confirmButtonText: 'Enable All Previews',
1027-
// rejectButtonText: 'No Thanks'
1028-
// }
1029-
// }
10301030
}
10311031

10321032
/*********************************************************
@@ -1359,7 +1359,8 @@ class DuckWidget {
13591359
fbElement.addEventListener('error', onError, { once: true })
13601360
}
13611361
}, { once: true })
1362-
unblockClickToLoadContent({ entity: this.entity, action: 'block-ctl-fb', isLogin })
1362+
const action = this.entity === 'Youtube' ? 'block-ctl-yt' : 'block-ctl-fb'
1363+
unblockClickToLoadContent({ entity: this.entity, action, isLogin })
13631364
}
13641365
}.bind(this)
13651366
// If this is a login button, show modal if needed
@@ -1595,7 +1596,8 @@ function unblockClickToLoadContent (message) {
15951596
}
15961597

15971598
function runLogin (entity) {
1598-
unblockClickToLoadContent({ entity, isLogin: true })
1599+
const action = this.entity === 'Youtube' ? 'block-ctl-yt' : 'block-ctl-fb'
1600+
unblockClickToLoadContent({ entity, action, isLogin: true })
15991601
originalWindowDispatchEvent(
16001602
createCustomEvent('ddg-ctp-run-login', {
16011603
detail: {

0 commit comments

Comments
 (0)