mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge with browser fixes from RossMods
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { getParsedUA, isMobile } from './RossAscends-mods.js';
|
||||
|
||||
const isFirefox = () => /firefox/i.test(navigator.userAgent);
|
||||
|
||||
function sanitizeInlineQuotationOnCopy() {
|
||||
@ -43,10 +45,34 @@ function sanitizeInlineQuotationOnCopy() {
|
||||
});
|
||||
}
|
||||
|
||||
function addSafariPatch() {
|
||||
const userAgent = getParsedUA();
|
||||
console.debug('User Agent', userAgent);
|
||||
const isMobileSafari = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
||||
const isDesktopSafari = userAgent?.browser?.name === 'Safari' && userAgent?.platform?.type === 'desktop';
|
||||
const isIOS = userAgent?.os?.name === 'iOS';
|
||||
|
||||
if (isIOS || isMobileSafari || isDesktopSafari) {
|
||||
document.body.classList.add('safari');
|
||||
}
|
||||
}
|
||||
|
||||
function applyBrowserFixes() {
|
||||
if (isFirefox()) {
|
||||
sanitizeInlineQuotationOnCopy();
|
||||
}
|
||||
|
||||
if (isMobile()) {
|
||||
const fixFunkyPositioning = () => {
|
||||
console.debug('[Mobile] Device viewport change detected.');
|
||||
document.documentElement.style.position = 'fixed';
|
||||
requestAnimationFrame(() => document.documentElement.style.position = '');
|
||||
};
|
||||
window.addEventListener('resize', fixFunkyPositioning);
|
||||
window.addEventListener('orientationchange', fixFunkyPositioning);
|
||||
}
|
||||
|
||||
addSafariPatch();
|
||||
}
|
||||
|
||||
export { isFirefox, applyBrowserFixes };
|
||||
|
Reference in New Issue
Block a user