Merge branch 'master' of github.com-greyhoof:greyhoof/fchat-rising into browser-option

This commit is contained in:
Greyhoof 2023-12-13 13:30:50 +01:00
commit e6981f03ee
22 changed files with 229 additions and 557 deletions

View File

@ -1,5 +1,12 @@
# Changelog
## 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))
* Fixed TikTok previews
* Switched `node-sass` to `sass` for ARM64 compatibility (Credit: [@WhiteHusky](https://github.com/WhiteHusky))
## 1.24.2
* Hotfix to address connectivity issues

View File

@ -1,9 +1,14 @@
# Contributors
> Want to contribute? Please [continue here](https://github.com/hearmeneigh/fchat-rising/wiki/Contributions).
This project contains contributions from:
* [Mr Stallion, esq.](https://github.com/hearmeneigh)
* [twilight-sparkle-irl](https://github.com/twilight-sparkle-irl)
* [ButterCheezii](https://github.com/ButterCheezii)
* [FatCatClient](https://github.com/FatCatClient)
* [WhiteHusky](https://github.com/WhiteHusky)
* [Abeehiltz](https://github.com/Abeehiltz)
* [greyhoof](https://github.com/greyhoof)
* [F-List Team](https://github.com/f-list) (original F-Chat 3.0 client)

View File

@ -127,7 +127,10 @@ export class BBCodeParser {
isAllowed = (name) => self.isAllowed(name) && parentAllowed(name);
currentTag = this._currentTag = {tag: self.tag, line: this._line, column: this._column};
}
let tagStart = -1, paramStart = -1, mark = start;
let tagStart = -1,
paramStart = -1,
mark = start,
isInCollapseParam = false;
for(let i = start; i < input.length; ++i) {
const c = input[i];
++this._column;
@ -135,12 +138,22 @@ export class BBCodeParser {
++this._line;
this._column = 1;
}
if(c === '[') {
if(c === '[' && !isInCollapseParam) {
tagStart = i;
paramStart = -1;
} else if(c === '=' && paramStart === -1)
paramStart = i;
} else if(c === '=' && paramStart === -1) {
paramStart = i;
const paramIndex = paramStart === -1 ? i : paramStart;
let tagKey = input
.substring(tagStart + 1, paramIndex)
.trim()
.toLowerCase();
if (tagKey == "collapse") isInCollapseParam = true;
}
else if(c === ']') {
const paramIndex = paramStart === -1 ? i : paramStart;
let tagKey = input.substring(tagStart + 1, paramIndex).trim().toLowerCase();
if(tagKey.length === 0) {
@ -154,6 +167,17 @@ export class BBCodeParser {
tagStart = -1;
continue;
}
if (isInCollapseParam) {
let fullTagKey = input
.substring(tagStart + 1, i + 1)
.trim()
.toLowerCase();
if (fullTagKey.endsWith("[hr]")) {
continue;
}
}
isInCollapseParam = false;
if(!close) {
const tag = this._tags[tagKey]!;
const allowed = isAllowed(tagKey);

View File

@ -72,8 +72,15 @@ export class StandardBBCodeParser extends CoreBBCodeParser {
const icon = parser.createElement('i');
icon.className = 'fas fa-chevron-down';
icon.style.marginRight = '10px';
headerText.appendChild(icon);
headerText.appendChild(document.createTextNode(param));
// HACK: to allow [hr] in header part
if (param.startsWith('[hr]')) { headerText.appendChild(parser.createElement('hr')); param = param.slice(4) }
headerText.appendChild(icon);
const splitParam = param.split('[hr]')
for (let iii = 0; iii < splitParam.length; iii++) {
const element = splitParam[iii];
headerText.appendChild(document.createTextNode(element));
if (iii < splitParam.length-1) headerText.appendChild(parser.createElement('hr'))
}
outer.appendChild(headerText);
const body = parser.createElement('div');
body.className = 'bbcode-collapse-body';

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

@ -189,7 +189,7 @@ Current log location: {1}`,
'settings.beta': 'Opt-in to test unstable prerelease updates',
'settings.hwAcceleration': 'Enable hardware acceleration (requires restart)',
'settings.bbCodeBar': 'Show BBCode formatting bar',
'settings.browserOption': 'Set command for opening clicked links',
'settings.browserOption': 'Set default browser',
'settings.browserOptionHeader': 'Browser Settings',
'settings.browserOptionTitle': 'Browser Path',
'settings.browserOptionPath': 'Path to browser executable',

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

@ -51,7 +51,7 @@ changelog: https://github.com/hearmeneigh/fchat-rising/blob/master/CHANGELOG.md
installurl: https://github.com/hearmeneigh/fchat-rising/wiki
download:
version: 1.24.2
version: 1.25.0
url: https://github.com/hearmeneigh/fchat-rising/releases/latest/download/F-Chat-Rising-%PLATFORM_TAIL%

View File

@ -24,9 +24,9 @@
<div>This is an advanced setting. By changing this setting to an unsupported program (i.e. not a browser), you might not be able to open links from F-Chat anymore.</div>
<div v-if="isMac"><hr/>
<p>Mac User: As of writing, MacOS has a bug in how it handles opening links.</p>
<p>When your default browser is something other than Safari and you select Safari in this settings window, links might be opened twice.</p>
<p>Once in Safari and a second time in your default browser. This tends to happen when Safari is not running when clicking a link.</p></div>
<p>Mac User: As of writing, MacOS has a bug in how it handles opening links.</p>
<p>When your default browser is something other than Safari and you select Safari in this settings window, links might be opened twice.</p>
<p>Once in Safari and a second time in your default browser. This tends to happen when Safari is not running when clicking a link.</p></div>
</div>
</div>
</div>
@ -57,13 +57,13 @@
</div>
<div class="form-group col-12">
<div class="row no-gutters">
<div class="col-2">
<button class="btn btn-primary" @click.prevent.stop="submit()">{{l('settings.browserOptionSave')}}</button>
</div>
<div class="col"></div>
<div class="col-4">
<button class="btn btn-danger" style="float: right;" @click.prevent.stop="resetToDefault()">{{l('settings.browserOptionReset')}}</button>
</div>
<div class="col"></div>
<div class="col-2">
<button class="btn btn-primary" @click.prevent.stop="submit()">{{l('settings.browserOptionSave')}}</button>
</div>
</div>
</div>
</div>

View File

@ -10,7 +10,7 @@ export class BlockerIntegration {
protected static readonly adBlockerLists = [
'https://easylist.to/easylist/easylist.txt',
'https://easylist.to/easylist/easyprivacy.txt', // EasyPrivacy
'https://easylist-downloads.adblockplus.org/easylist-cookie.txt', // Easy Cookies
'https://secure.fanboy.co.nz/fanboy-cookiemonster.txt', // Easy Cookies
'https://easylist.to/easylist/fanboy-social.txt', // Fanboy Social
'https://easylist.to/easylist/fanboy-annoyance.txt', // Fanboy Annoyances
'https://filters.adtidy.org/extension/chromium/filters/2.txt', // AdGuard Base

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);

View File

@ -1,6 +1,6 @@
{
"name": "fchat",
"version": "1.24.2",
"version": "1.25.0",
"author": "The F-List Team and Mister Stallion (Esq.)",
"description": "F-List.net Chat Client",
"main": "main.js",

4
electron/yarn.lock Normal file
View File

@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

View File

@ -1,6 +1,6 @@
{
"name": "f-list-rising",
"version": "1.24.2",
"version": "1.25.0",
"author": "The F-List Team and and Mister Stallion (Esq.)",
"description": "A heavily modded F-Chat 3.0 client for F-List",
"license": "MIT",
@ -12,7 +12,6 @@
"@types/bluebird": "3.5.32",
"@types/lodash": "4.14.162",
"@types/node": "16.18.32",
"@types/node-fetch": "2.6.4",
"@types/vue-clickaway": "2.2.0",
"@types/qs": "^6.9.5",
"@types/request-promise": "^4.1.46",
@ -22,7 +21,7 @@
"async": "^0.9.0",
"axios": "^0.21.4",
"bluebird": "~3.7.2",
"bootstrap": "^4.5.3",
"bootstrap": "^4.6.2",
"copy-webpack-plugin": "^6.2.1",
"css-loader": "^5.0.0",
"date-fns": "2.29.3",
@ -34,7 +33,7 @@
"extract-loader": "^5.1.0",
"file-loader": "^6.2.0",
"lodash": "^4.17.20",
"node-sass": "^7.0.1",
"sass": "^1.68.0",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"qs": "^6.9.4",
"raven-js": "^3.27.2",
@ -58,14 +57,14 @@
"webpack": "5.8.0"
},
"dependencies": {
"@cliqz/adblocker-electron": "1.23.9",
"jquery": "^3.6.0",
"node-fetch": "2.6.11"
"@cliqz/adblocker-electron": "^1.26.12",
"jquery": "^3.7.1",
"node-fetch": "^2.7.0"
},
"optionalDependencies": {
"appdmg": "^0.6.0",
"electron-squirrel-startup": "^1.0.0",
"electron-winstaller": "^5.0.0"
"electron-winstaller": "^5.2.1"
},
"resolutions": {
"vue": "2.6.12",
@ -73,11 +72,7 @@
"vue-loader": "15.9.8",
"vue-template-compiler": "2.6.12",
"@types/bluebird": "3.5.32",
"@types/node": "16.18.32",
"@cliqz/adblocker": "1.23.9",
"@cliqz/adblocker-content": "1.23.9",
"@cliqz/adblocker-electron-preload": "1.23.9",
"@cliqz/adblocker-extended-selectors": "1.23.9"
"@types/node": "16.18.32"
},
"scripts": {
"__removed__postinstall": "electron-rebuild --prebuild-tag-prefix=ignoreprebuilds -f -o keytar",

View File

@ -6,7 +6,7 @@
"license": "MIT",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.1",
"bootstrap": "^4.5.3",
"bootstrap": "^4.6.2",
"node-sass": "^7.0.2",
"@snyk/protect": "latest"
},

View File

@ -82,3 +82,13 @@ export function init(s: Settings, c: SimpleCharacter[]): void {
settings = s;
characters = c;
}
function escapeRegExp(string: string):
string {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}
export function replaceAll(str: string, find: string, replace: string):
string {
return str.replace(new RegExp(escapeRegExp(find), "g"), replace);
}

625
yarn.lock

File diff suppressed because it is too large Load Diff