2019-06-08 03:45:35 +02:00
|
|
|
<template>
|
2019-07-02 00:57:43 +02:00
|
|
|
<div class="flex flex-column" style="padding-bottom: 20px">
|
2019-08-13 21:21:35 +02:00
|
|
|
<div class="">
|
|
|
|
<div class="label">Player picker</div>
|
|
|
|
<div class="desc">
|
|
|
|
If extension doesn't detect player correctly, you can override it.
|
|
|
|
<small>(NOTE: this currently doesn't work for embedded videos)</small>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>Meaning of outlines:</div>
|
|
|
|
|
|
|
|
<div class="flex flex-row flex-wrap">
|
|
|
|
<div class="pp_video flex flex-nogrow"><code><video></code> element</div>
|
|
|
|
<div class="pp_current flex flex-nogrow">Selected element</div>
|
|
|
|
<div class="pp_matched flex flex-nogrow">Matched by query string</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-row">
|
|
|
|
<ShortcutButton label="Move up"
|
|
|
|
/>
|
|
|
|
<ShortcutButton label="Move down"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-row flex-wrap">
|
|
|
|
<QsElement selector="#test_id" />
|
|
|
|
<QsElement selector=".test_class" />
|
|
|
|
<template v-for="qse of currentElementQs" >
|
|
|
|
<QsElement :selector="qse" :key="qse" />
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2019-06-10 23:45:15 +02:00
|
|
|
<div class="label">
|
|
|
|
Video detection settings<br/><small>for {{site}}</small>
|
|
|
|
</div>
|
2019-06-08 03:45:35 +02:00
|
|
|
<div class="description">Video is just the moving picture bit without the player.</div>
|
2019-06-10 23:45:15 +02:00
|
|
|
<div class="">
|
|
|
|
<div class="">
|
|
|
|
<input :checked="!videoManualQs"
|
|
|
|
@change="toggleVideoManualQs"
|
|
|
|
type="checkbox"
|
|
|
|
/> Detect automatically
|
2019-06-08 03:45:35 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex flex-column">
|
|
|
|
<div class="flex label-secondary form-label">Query selectors</div>
|
2019-06-10 23:45:15 +02:00
|
|
|
<input type="text"
|
|
|
|
v-model="videoQs"
|
|
|
|
:disabled="!videoManualQs"
|
|
|
|
@change="updateVideoQuerySelector"
|
|
|
|
@blur="updateVideoQuerySelector"
|
2019-06-08 03:45:35 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2019-06-11 01:34:02 +02:00
|
|
|
<div class="flex flex-column">
|
|
|
|
<div class="flex label-secondary form-label">Additional css</div>
|
|
|
|
<input type="text"
|
|
|
|
v-model="videoCss"
|
|
|
|
@change="updateVideoCss"
|
|
|
|
@blur="updateVideoCss"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2019-06-08 03:45:35 +02:00
|
|
|
</div>
|
|
|
|
|
2019-06-10 23:45:15 +02:00
|
|
|
<div class="label">
|
|
|
|
Player detection settings<br/><small>for {{site}}</small>
|
|
|
|
</div>
|
|
|
|
<div class="description">
|
|
|
|
Player is the frame around the video. Extension crops/stretches the video to fit the player.
|
|
|
|
</div>
|
|
|
|
<div class="">
|
|
|
|
<div class="">
|
|
|
|
<input :checked="!playerManualQs"
|
|
|
|
@change="togglePlayerManualQs"
|
|
|
|
type="checkbox"
|
|
|
|
/> Detect automatically
|
2019-06-08 03:45:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-column">
|
2019-06-10 23:45:15 +02:00
|
|
|
<div class="">Query selectors:</div>
|
|
|
|
<input type="text"
|
|
|
|
v-model="playerQs"
|
|
|
|
@change="updatePlayerQuerySelector"
|
|
|
|
@blur="updatePlayerQuerySelector"
|
|
|
|
:disabled="playerByNodeIndex || !playerManualQs"
|
2019-06-08 03:45:35 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2019-06-10 23:45:15 +02:00
|
|
|
<div class="">
|
|
|
|
<input :checked="playerByNodeIndex"
|
|
|
|
:disabled="!playerManualQs"
|
|
|
|
@change="toggleByNodeIndex"
|
|
|
|
type="checkbox"
|
|
|
|
/> Specify player node parent index instead
|
2019-06-08 03:45:35 +02:00
|
|
|
</div>
|
|
|
|
|
2019-06-10 23:45:15 +02:00
|
|
|
<div class="flex flex-column">
|
|
|
|
<div class="">Player node parent index:</div>
|
|
|
|
<input v-model="playerParentNodeIndex"
|
|
|
|
:disabled="!playerByNodeIndex || !playerManualQs"
|
|
|
|
@change="updatePlayerParentNodeIndex"
|
|
|
|
@blur="updatePlayerParentNodeIndex"
|
|
|
|
type="number"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-06-14 02:15:24 +02:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="label">
|
|
|
|
Additional css<br/><small>for {{site}}</small>
|
|
|
|
</div>
|
|
|
|
<div class="description">
|
|
|
|
This css will be inserted into webpage every time it loads.
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column">
|
|
|
|
<textarea
|
2019-06-11 01:34:02 +02:00
|
|
|
v-model="playerCss"
|
|
|
|
@change="updatePlayerCss"
|
|
|
|
@blur="updatePlayerCss"
|
2019-06-14 02:15:24 +02:00
|
|
|
>
|
|
|
|
</textarea>
|
2019-06-11 01:34:02 +02:00
|
|
|
</div>
|
2019-06-08 03:45:35 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-08-13 21:21:35 +02:00
|
|
|
import ShortcutButton from '../../common/components/ShortcutButton.vue';
|
|
|
|
import QsElement from '../../common/components/QsElement.vue';
|
2019-06-08 03:45:35 +02:00
|
|
|
import QuerySelectorSetting from '../../common/components/QuerySelectorSetting.vue';
|
|
|
|
import ExtensionMode from '../../common/enums/extension-mode.enum';
|
|
|
|
import VideoAlignment from '../../common/enums/video-alignment.enum';
|
|
|
|
import Stretch from '../../common/enums/stretch.enum';
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
QuerySelectorSetting,
|
2019-08-13 21:21:35 +02:00
|
|
|
ShortcutButton,
|
|
|
|
QsElement,
|
2019-06-08 03:45:35 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2019-06-10 23:45:15 +02:00
|
|
|
videoManualQs: false,
|
|
|
|
videoQs: '',
|
2019-06-11 01:34:02 +02:00
|
|
|
videoCss: '',
|
2019-06-10 23:45:15 +02:00
|
|
|
playerManualQs: false,
|
|
|
|
playerQs: '',
|
2019-06-11 01:34:02 +02:00
|
|
|
playerCss: '',
|
2019-06-10 23:45:15 +02:00
|
|
|
playerByNodeIndex: false,
|
|
|
|
playerParentNodeIndex: undefined,
|
2019-06-08 03:45:35 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
site: String,
|
|
|
|
settings: Object,
|
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
created() {
|
2019-06-14 22:36:21 +02:00
|
|
|
console.log("created!")
|
2019-06-10 23:45:15 +02:00
|
|
|
try {
|
2019-06-14 22:36:21 +02:00
|
|
|
this.videoManualQs = this.settings.active.sites[this.site].DOM.video.manual || this.videoManualQs;
|
|
|
|
this.videoQs = this.settings.active.sites[this.site].DOM.video.querySelectors;
|
|
|
|
this.videoCss = this.settings.active.sites[this.site].DOM.video.additionalCss;
|
2019-06-10 23:45:15 +02:00
|
|
|
} catch (e) {
|
|
|
|
// that's here just in case relevant settings for this site don't exist yet
|
2019-06-14 22:36:21 +02:00
|
|
|
console.log("failed to load settings for the site — for video stuff")
|
2019-06-10 23:45:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2019-06-14 22:36:21 +02:00
|
|
|
this.playerManualQs = this.settings.active.sites[this.site].DOM.player.manual || this.playerManualQs;
|
|
|
|
this.playerQs = this.settings.active.sites[this.site].DOM.player.querySelectors;
|
|
|
|
this.playerByNodeIndex = this.settings.active.sites[this.site].DOM.player.useRelativeAncestor || this.playerByNodeIndex;
|
|
|
|
this.playerParentNodeIndex = this.settings.active.sites[this.site].DOM.player.videoAncestor;
|
2019-06-10 23:45:15 +02:00
|
|
|
} catch (e) {
|
|
|
|
// that's here just in case relevant settings for this site don't exist yet
|
2019-06-14 22:36:21 +02:00
|
|
|
console.log("failed to load settings for the site — for video stuff")
|
2019-06-08 03:45:35 +02:00
|
|
|
}
|
2019-06-14 02:15:24 +02:00
|
|
|
|
|
|
|
try {
|
2019-06-14 22:36:21 +02:00
|
|
|
this.playerCss = this.settings.active.sites[this.site].css || '';
|
2019-06-14 02:15:24 +02:00
|
|
|
} catch (e) {
|
|
|
|
// that's here just in case relevant settings for this site don't exist yet
|
2019-06-14 22:36:21 +02:00
|
|
|
console.log("failed to load settings for the site — for video stuff")
|
2019-06-14 02:15:24 +02:00
|
|
|
}
|
2019-06-14 22:36:21 +02:00
|
|
|
console.log("created — got settings:", this.settings)
|
2019-06-08 03:45:35 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
ensureSettings(scope) {
|
|
|
|
if (! this.settings.active.sites[this.site]) {
|
|
|
|
this.settings.active.sites[this.site] = {
|
|
|
|
mode: ExtensionMode.Default,
|
|
|
|
autoar: ExtensionMode.Default,
|
|
|
|
type: 'user-added',
|
|
|
|
stretch: Stretch.Default,
|
|
|
|
videoAlignment: VideoAlignment.Default,
|
|
|
|
keyboardShortcutsEnabled: ExtensionMode.Default,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (! this.settings.active.sites[this.site].DOM) {
|
|
|
|
this.settings.active.sites[this.site].DOM = {};
|
|
|
|
}
|
|
|
|
if (! this.settings.active.sites[this.site].DOM[scope]) {
|
|
|
|
this.settings.active.sites[this.site].DOM[scope] = {
|
2019-06-10 23:45:15 +02:00
|
|
|
manual: false,
|
|
|
|
querySelectors: '',
|
2019-06-11 01:34:02 +02:00
|
|
|
additionalCss: '',
|
2019-06-10 23:45:15 +02:00
|
|
|
useRelativeAncestor: scope === 'player' ? false : undefined,
|
|
|
|
videoAncestor: undefined,
|
|
|
|
playerNodeCss: scope === 'player' ? '' : undefined,
|
2019-06-08 03:45:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
updateVideoQuerySelector() {
|
|
|
|
this.ensureSettings('video');
|
|
|
|
this.settings.active.sites[this.site].DOM.video.querySelectors = this.videoQs;
|
2019-06-08 03:45:35 +02:00
|
|
|
this.settings.save();
|
|
|
|
},
|
2019-06-11 01:34:02 +02:00
|
|
|
updateVideoCss() {
|
|
|
|
this.ensureSettings('video');
|
|
|
|
this.settings.active.sites[this.site].DOM.video.additionalCss = this.videoCss;
|
|
|
|
this.settings.save();
|
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
updatePlayerQuerySelector() {
|
|
|
|
this.ensureSettings('player');
|
|
|
|
this.settings.active.sites[this.site].DOM.player.querySelectors = this.playerQs;
|
|
|
|
this.settings.save();
|
2019-06-08 03:45:35 +02:00
|
|
|
},
|
2019-06-14 02:15:24 +02:00
|
|
|
updatePlayerCss() {
|
2019-06-11 01:34:02 +02:00
|
|
|
this.ensureSettings('player');
|
2019-06-14 02:15:24 +02:00
|
|
|
this.settings.active.sites[this.site].css = this.playerCss;
|
2019-06-11 01:34:02 +02:00
|
|
|
this.settings.save();
|
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
updatePlayerParentNodeIndex() {
|
|
|
|
this.ensureSettings('player');
|
|
|
|
this.settings.active.sites[this.site].DOM.player.videoAncestor = this.playerParentNodeIndex;
|
|
|
|
this.settings.save();
|
2019-06-08 03:45:35 +02:00
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
toggleVideoManualQs() {
|
2019-06-08 03:45:35 +02:00
|
|
|
this.ensureSettings('video');
|
2019-06-10 23:45:15 +02:00
|
|
|
this.videoManualQs = !this.videoManualQs;
|
2019-06-24 14:05:37 +02:00
|
|
|
this.settings.active.sites[this.site].DOM.video.manual = this.videoManualQs;
|
2019-06-08 03:45:35 +02:00
|
|
|
this.settings.save();
|
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
togglePlayerManualQs() {
|
2019-06-08 03:45:35 +02:00
|
|
|
this.ensureSettings('player');
|
2019-06-10 23:45:15 +02:00
|
|
|
this.playerManualQs = !this.playerManualQs;
|
2019-06-24 14:05:37 +02:00
|
|
|
this.settings.active.sites[this.site].DOM.player.manual = this.playerManualQs;
|
2019-06-08 03:45:35 +02:00
|
|
|
this.settings.save();
|
|
|
|
},
|
2019-06-10 23:45:15 +02:00
|
|
|
toggleByNodeIndex() {
|
2019-06-08 03:45:35 +02:00
|
|
|
this.ensureSettings('player');
|
2019-06-10 23:45:15 +02:00
|
|
|
this.playerByNodeIndex = !this.playerByNodeIndex;
|
2019-06-14 02:15:24 +02:00
|
|
|
this.settings.active.sites[this.site].DOM.player.useRelativeAncestor = this.playerByNodeIndex;
|
2019-06-08 03:45:35 +02:00
|
|
|
this.settings.save();
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2019-08-13 21:21:35 +02:00
|
|
|
.pp_video {
|
|
|
|
margin: 2px;
|
|
|
|
padding: 5px;
|
|
|
|
border: 1px solid red;
|
|
|
|
}
|
|
|
|
.pp_current {
|
|
|
|
margin: 2px;
|
|
|
|
padding: 5px;
|
|
|
|
border: 1px solid #88f;
|
|
|
|
}
|
|
|
|
.pp_matched {
|
|
|
|
margin: 2px;
|
|
|
|
padding: 5px;
|
|
|
|
border: 1px dashed #fd2;
|
|
|
|
}
|
2019-06-08 03:45:35 +02:00
|
|
|
</style>
|