fixed tiktok previews

This commit is contained in:
Mr. Stallion 2023-12-02 16:41:17 -08:00
parent 6373556cbd
commit 760885946f
9 changed files with 42 additions and 8 deletions

View File

@ -6,11 +6,12 @@
* Profile Helper now only shows up if you have anything to fix; otherwise the profile helper can be found in the Settings menu
## 1.25.0
* Added option for switching browsers (Credit: [@greyhoof](https://github.com/greyhoof))
* Fixed broken adblocker
* Fixed incorrect BBCode rendering of `[collapse=[hr]test[hr]]` (Credit: [@Abeehiltz](https://github.com/Abeehiltz))
* Added option for switching browsers (Credit: [@greyhoof](https://github.com/greyhoof))
* Switched `node-sass` to `sass` for ARM64 compatibility (Credit: [@WhiteHusky](https://github.com/WhiteHusky))
## 1.24.2
* Hotfix to address connectivity issues

View File

@ -2,8 +2,8 @@
<div style="height:100%; display: flex; position: relative;" id="chatView" @click="userMenuHandle" @contextmenu="userMenuHandle" @touchstart.passive="userMenuHandle"
@touchend="userMenuHandle">
<sidebar id="sidebar" :label="l('chat.menu')" icon="fa-bars">
<img :src="characterImage(ownCharacter.name)" v-if="showAvatars" style="float:left;margin-right:5px;width:60px"/>
<a target="_blank" :href="ownCharacterLink" class="btn" style="margin-right:5px">{{ownCharacter.name}}</a>
<img :src="characterImage(ownCharacter.name)" v-if="showAvatars" style="float:left;margin-right:5px;margin-top:5px;width:70px"/>
<a target="_blank" :href="ownCharacterLink" class="btn" style="display:block">{{ownCharacter.name}}</a>
<a href="#" @click.prevent="logOut()" class="btn"><i class="fas fa-sign-out-alt"></i>{{l('chat.logout')}}</a><br/>
<div>
{{l('chat.status')}}

View File

@ -90,7 +90,7 @@ export class AdManager {
}
private determineNextAdDelayMs(chanConv: Conversation.ChannelConversation): number {
const match = chanConv.channel.description.toLowerCase().match(/\[\s*ads:\s*([0-9.]+)\s*(m|min|minutes?|h|hr|hours?|s|secs?|seconds?)\s*]/);
const match = chanConv.channel.description.toLowerCase().match(/\[\s*ads:\s*([0-9.]+)\s*(m|mins?|minutes?|h|hrs?|hours?|s|secs?|seconds?)\.?\s*]/);
if (!match) {
return AdManager.POST_DELAY;
@ -105,7 +105,7 @@ export class AdManager {
mul = 60 * 1000; // minutes
}
return Math.max((n * mul) - (Date.now() - chanConv.nextAd), AdManager.POST_DELAY);
return Math.max((n * mul) - Math.max(Date.now() - chanConv.nextAd, 0), AdManager.POST_DELAY);
}
private async sendNextPost(): Promise<void> {

View File

@ -560,6 +560,8 @@
async executeJavaScript(js: string | undefined, context: string = 'unknown', logDetails?: any): Promise<any> {
console.log('EXECUTE JS', js);
if (!this.runJs) return;
const webview = this.getWebview();

View File

@ -80,7 +80,7 @@ class FListImagePreviewDomMutator {
const img = selected.filter(el => (el !== body)).shift();
this.debug('detectImage.found', !!img, img);
this.debug('detectImage.found', !!img, img, body);
return img;
}

View File

@ -110,10 +110,11 @@ export class ExternalImagePreviewHelper extends ImagePreviewHelper {
this.ratio = null;
webview.stop();
webview.setAudioMuted(true);
// Broken promise chain on purpose
// tslint:disable-next-line:no-floating-promises
this.urlMutator.resolve(url)
void this.urlMutator.resolve(url)
.then(
async(finalUrl: string) => {
if (this.debug)
@ -121,7 +122,9 @@ export class ExternalImagePreviewHelper extends ImagePreviewHelper {
webview.stop();
return webview.loadURL(finalUrl);
await webview.loadURL(finalUrl);
webview.setAudioMuted(true);
}
)
.catch(

View File

@ -181,6 +181,11 @@ export class ImageDomMutator {
this.getBaseJsMutatorScript([/*'#__flistCore', '#player', */ '#photoImageSection img', 'video', 'img', '#player'], false)
);
this.add(
'tiktokstalk.com',
this.getBaseJsMutatorScript(['video'], false, [], true, true)
);
this.add(
'gifmixxx.com',

View File

@ -33,6 +33,23 @@ export class ImageUrlMutator {
}
protected init(): void {
this.add(
/^https?:\/\/(www\.)?tiktok\.com\//,
async(url: string, _match: RegExpMatchArray): Promise<string> => {
const result = await Axios.get(
`https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`,
{
responseType: 'json'
}
);
const userId = result.data.author_unique_id;
const videoId = result.data.embed_product_id;
return `https://www.tiktokstalk.com/user/${userId}/${videoId}/`;
}
);
this.add(
/^http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?/,
async(_url: string, match: RegExpMatchArray): Promise<string> => {
@ -40,6 +57,7 @@ export class ImageUrlMutator {
return `https://yewtu.be/embed/${videoId}?autoplay=1`
}
);
this.add(
/^https?:\/\/.*twitter.com\/(.*)/,
async(url: string, match: RegExpMatchArray): Promise<string> => {

View File

@ -303,6 +303,11 @@ export class SettingsStore implements Settings.Store {
async get<K extends keyof Settings.Keys>(key: K, character?: string): Promise<Settings.Keys[K] | undefined> {
try {
const file = path.join(getSettingsDir(character), key);
if (!fs.existsSync(file)) {
return undefined;
}
return <Settings.Keys[K]>JSON.parse(fs.readFileSync(file, 'utf8'));
} catch(e) {
console.error('READ KEY FAILURE', e, key, character);