From 81b00d3ac74c10389f2df747975516fa8de5f71d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 24 Sep 2021 20:24:58 +0200 Subject: [PATCH] Make logs unselectable to force people clicking the damn share button >_> --- app/src/App.vue | 30 ++++++++++++++++++++++-------- app/src/scss/main.scss | 8 ++++++++ app/src/views/tool/ToolLog.vue | 11 +++++++++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/app/src/App.vue b/app/src/App.vue index 4325545a..e5e2673a 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -125,17 +125,31 @@ export default { }, mounted () { - // Konamicode ;P - const konamiCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'] - let step = 0 + // Unlock copypasta on log view + const copypastaCode = ['ArrowDown', 'ArrowDown', 'ArrowUp', 'ArrowUp'] + let copypastastep = 0 document.addEventListener('keydown', ({ key }) => { - if (key === konamiCode[step++]) { - if (step === konamiCode.length) { - this.$store.commit('SET_SPINNER', 'nyancat') - step = 0 + if (key === copypastaCode[copypastastep++]) { + if (copypastastep === copypastaCode.length) { + document.getElementsByClassName("unselectable").forEach((element) => element.classList.remove("unselectable")) + copypastastep = 0 } } else { - step = 0 + copypastastep = 0 + } + }) + + // Konamicode ;P + const konamiCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'] + let konamistep = 0 + document.addEventListener('keydown', ({ key }) => { + if (key === konamiCode[konamistep++]) { + if (konamistep === konamiCode.length) { + this.$store.commit('SET_SPINNER', 'nyancat') + konamistep = 0 + } + } else { + konamistep = 0 } }) diff --git a/app/src/scss/main.scss b/app/src/scss/main.scss index 566d0b6a..b87594cb 100644 --- a/app/src/scss/main.scss +++ b/app/src/scss/main.scss @@ -175,3 +175,11 @@ code { background-color: $light; overflow: auto; } + +.unselectable { + -webkit-user-select: none; + -webkit-touch-callout: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/app/src/views/tool/ToolLog.vue b/app/src/views/tool/ToolLog.vue index 7ca3ba4f..4b5823ff 100644 --- a/app/src/views/tool/ToolLog.vue +++ b/app/src/views/tool/ToolLog.vue @@ -50,12 +50,19 @@ {{ $t('logs_more') }} -
- +
{{ $t('logs_share_with_yunopaste') }} + + +

+ Text selection is disabled. If you want to share this log, please share the *full* log with the 'Share with Yunopaste' button. +
+ Or if you really really want to select text, press these keys: ↓↓↑↑. +

+