Prevent middle click from opening URLs within the app
This commit is contained in:
parent
24265613e7
commit
2be2301d92
|
@ -41,7 +41,6 @@ export default Vue.extend({
|
||||||
latestBlogUrl: '',
|
latestBlogUrl: '',
|
||||||
updateChangelog: '',
|
updateChangelog: '',
|
||||||
changeLogTitle: '',
|
changeLogTitle: '',
|
||||||
|
|
||||||
lastExternalLinkToBeOpened: '',
|
lastExternalLinkToBeOpened: '',
|
||||||
showExternalLinkOpeningPrompt: false,
|
showExternalLinkOpeningPrompt: false,
|
||||||
externalLinkOpeningPromptValues: [
|
externalLinkOpeningPromptValues: [
|
||||||
|
@ -313,32 +312,40 @@ export default Vue.extend({
|
||||||
|
|
||||||
openAllLinksExternally: function () {
|
openAllLinksExternally: function () {
|
||||||
$(document).on('click', 'a[href^="http"]', (event) => {
|
$(document).on('click', 'a[href^="http"]', (event) => {
|
||||||
const el = event.currentTarget
|
this.handleLinkClick(event)
|
||||||
console.log(this.usingElectron)
|
|
||||||
console.log(el)
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
// Check if it's a YouTube link
|
|
||||||
const youtubeUrlPattern = /^https?:\/\/((www\.)?youtube\.com(\/embed)?|youtu\.be)\/.*$/
|
|
||||||
const isYoutubeLink = youtubeUrlPattern.test(el.href)
|
|
||||||
|
|
||||||
if (isYoutubeLink) {
|
|
||||||
this.handleYoutubeLink(el.href)
|
|
||||||
} else if (this.externalLinkHandling === 'doNothing') {
|
|
||||||
// Let user know opening external link is disabled via setting
|
|
||||||
this.showToast({
|
|
||||||
message: this.$t('External link opening has been disabled in the general settings')
|
|
||||||
})
|
|
||||||
} else if (this.externalLinkHandling === 'openLinkAfterPrompt') {
|
|
||||||
// Storing the URL is necessary as
|
|
||||||
// there is no other way to pass the URL to click callback
|
|
||||||
this.lastExternalLinkToBeOpened = el.href
|
|
||||||
this.showExternalLinkOpeningPrompt = true
|
|
||||||
} else {
|
|
||||||
// Open links externally
|
|
||||||
this.openExternalLink(el.href)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$(document).on('auxclick', 'a[href^="http"]', (event) => {
|
||||||
|
this.handleLinkClick(event)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
handleLinkClick: function (event) {
|
||||||
|
const el = event.currentTarget
|
||||||
|
console.log(this.usingElectron)
|
||||||
|
console.log(el)
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
// Check if it's a YouTube link
|
||||||
|
const youtubeUrlPattern = /^https?:\/\/((www\.)?youtube\.com(\/embed)?|youtu\.be)\/.*$/
|
||||||
|
const isYoutubeLink = youtubeUrlPattern.test(el.href)
|
||||||
|
|
||||||
|
if (isYoutubeLink) {
|
||||||
|
this.handleYoutubeLink(el.href)
|
||||||
|
} else if (this.externalLinkHandling === 'doNothing') {
|
||||||
|
// Let user know opening external link is disabled via setting
|
||||||
|
this.showToast({
|
||||||
|
message: this.$t('External link opening has been disabled in the general settings')
|
||||||
|
})
|
||||||
|
} else if (this.externalLinkHandling === 'openLinkAfterPrompt') {
|
||||||
|
// Storing the URL is necessary as
|
||||||
|
// there is no other way to pass the URL to click callback
|
||||||
|
this.lastExternalLinkToBeOpened = el.href
|
||||||
|
this.showExternalLinkOpeningPrompt = true
|
||||||
|
} else {
|
||||||
|
// Open links externally
|
||||||
|
this.openExternalLink(el.href)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleYoutubeLink: function (href) {
|
handleYoutubeLink: function (href) {
|
||||||
|
@ -445,15 +452,16 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
...mapMutations([
|
|
||||||
'setInvidiousInstancesList'
|
|
||||||
]),
|
|
||||||
|
|
||||||
setWindowTitle: function() {
|
setWindowTitle: function() {
|
||||||
if (this.windowTitle !== null) {
|
if (this.windowTitle !== null) {
|
||||||
document.title = this.windowTitle
|
document.title = this.windowTitle
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
...mapMutations([
|
||||||
|
'setInvidiousInstancesList'
|
||||||
|
]),
|
||||||
|
|
||||||
...mapActions([
|
...mapActions([
|
||||||
'showToast',
|
'showToast',
|
||||||
'openExternalLink',
|
'openExternalLink',
|
||||||
|
|
|
@ -1620,12 +1620,6 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
...mapActions([
|
|
||||||
'calculateColorLuminance',
|
|
||||||
'updateDefaultCaptionSettings',
|
|
||||||
'showToast',
|
|
||||||
'sponsorBlockSkipSegments'
|
|
||||||
]),
|
|
||||||
addPlayerStatsEvent: function() {
|
addPlayerStatsEvent: function() {
|
||||||
this.stats.videoId = this.videoId
|
this.stats.videoId = this.videoId
|
||||||
this.player.on('volumechange', () => {
|
this.player.on('volumechange', () => {
|
||||||
|
@ -1704,6 +1698,13 @@ export default Vue.extend({
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
...mapActions([
|
||||||
|
'calculateColorLuminance',
|
||||||
|
'updateDefaultCaptionSettings',
|
||||||
|
'showToast',
|
||||||
|
'sponsorBlockSkipSegments'
|
||||||
|
])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue