Show alert for masked urls
This commit is contained in:
parent
83ba6deffe
commit
aff64e5390
@ -403,6 +403,9 @@ const lang = {
|
|||||||
"HidAccount": "The account was hidden by the user",
|
"HidAccount": "The account was hidden by the user",
|
||||||
"TelegramFeatures": "Telegram Features",
|
"TelegramFeatures": "Telegram Features",
|
||||||
"SetColor": "Set a color",
|
"SetColor": "Set a color",
|
||||||
|
"Open": "Open",
|
||||||
|
"OpenUrlTitle": "Open Link",
|
||||||
|
"OpenUrlAlert2": "Do you want to open %1$s?",
|
||||||
|
|
||||||
// * macos
|
// * macos
|
||||||
"AccountSettings.Filters": "Chat Folders",
|
"AccountSettings.Filters": "Chat Folders",
|
||||||
|
@ -49,6 +49,7 @@ import { hslaStringToHex } from '../../helpers/color';
|
|||||||
import { copy, getObjectKeysAndSort } from '../../helpers/object';
|
import { copy, getObjectKeysAndSort } from '../../helpers/object';
|
||||||
import { getFilesFromEvent } from '../../helpers/files';
|
import { getFilesFromEvent } from '../../helpers/files';
|
||||||
import PeerTitle from '../../components/peerTitle';
|
import PeerTitle from '../../components/peerTitle';
|
||||||
|
import PopupPeer from '../../components/popups/peer';
|
||||||
|
|
||||||
//console.log('appImManager included33!');
|
//console.log('appImManager included33!');
|
||||||
|
|
||||||
@ -172,6 +173,30 @@ export class AppImManager {
|
|||||||
sessionStorage.get('chatPositions').then((c) => {
|
sessionStorage.get('chatPositions').then((c) => {
|
||||||
sessionStorage.setToCache('chatPositions', c || {});
|
sessionStorage.setToCache('chatPositions', c || {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
(window as any).showMaskedAlert = (element: HTMLAnchorElement, e: Event) => {
|
||||||
|
cancelEvent(null);
|
||||||
|
|
||||||
|
const href = element.href;
|
||||||
|
|
||||||
|
const a = element.cloneNode(true) as HTMLAnchorElement;
|
||||||
|
a.innerText = href;
|
||||||
|
a.removeAttribute('onclick');
|
||||||
|
|
||||||
|
new PopupPeer('popup-masked-url', {
|
||||||
|
titleLangKey: 'OpenUrlTitle',
|
||||||
|
descriptionLangKey: 'OpenUrlAlert2',
|
||||||
|
descriptionLangArgs: [a],
|
||||||
|
buttons: [{
|
||||||
|
langKey: 'Open',
|
||||||
|
callback: () => {
|
||||||
|
a.click();
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
}).show();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private onHashChange = () => {
|
private onHashChange = () => {
|
||||||
|
@ -384,7 +384,8 @@ namespace RichTextProcessor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const entity of entities) {
|
for(let i = 0, length = entities.length; i < length; ++i) {
|
||||||
|
const entity = entities[i];
|
||||||
switch(entity._) {
|
switch(entity._) {
|
||||||
case 'messageEntityBold': {
|
case 'messageEntityBold': {
|
||||||
if(!options.noTextFormat) {
|
if(!options.noTextFormat) {
|
||||||
@ -506,9 +507,18 @@ namespace RichTextProcessor {
|
|||||||
|
|
||||||
let inner: string;
|
let inner: string;
|
||||||
let url: string;
|
let url: string;
|
||||||
|
let masked = false;
|
||||||
if(entity._ === 'messageEntityTextUrl') {
|
if(entity._ === 'messageEntityTextUrl') {
|
||||||
url = (entity as MessageEntity.messageEntityTextUrl).url;
|
url = (entity as MessageEntity.messageEntityTextUrl).url;
|
||||||
url = wrapUrl(url, true);
|
url = wrapUrl(url, true);
|
||||||
|
|
||||||
|
const nextEntity = entities[i + 1];
|
||||||
|
if(nextEntity?._ === 'messageEntityUrl' &&
|
||||||
|
nextEntity.length === entity.length &&
|
||||||
|
nextEntity.offset === entity.offset) {
|
||||||
|
i++;
|
||||||
|
masked = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
url = wrapUrl(entityText, false);
|
url = wrapUrl(entityText, false);
|
||||||
//inner = encodeEntities(replaceUrlEncodings(entityText));
|
//inner = encodeEntities(replaceUrlEncodings(entityText));
|
||||||
@ -516,7 +526,7 @@ namespace RichTextProcessor {
|
|||||||
|
|
||||||
const currentContext = url[0] === '#';
|
const currentContext = url[0] === '#';
|
||||||
|
|
||||||
insertPart(entity, `<a class="anchor-url" href="${encodeEntities(url)}"${currentContext ? '' : ' target="_blank" rel="noopener noreferrer"'}>`, '</a>');
|
insertPart(entity, `<a class="anchor-url" href="${encodeEntities(url)}"${currentContext ? '' : ' target="_blank" rel="noopener noreferrer"'}${masked ? 'onclick="showMaskedAlert(this)"' : ''}>`, '</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user