fix: RoleColorEverywhere, PictureInPicture, NoMosaic (#2356)
This commit is contained in:
parent
52f8a85ab9
commit
356a2c290d
4 changed files with 10 additions and 75 deletions
|
@ -5,15 +5,9 @@
|
|||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
import style from "./styles.css?managed";
|
||||
|
||||
const MAX_WIDTH = 550;
|
||||
const MAX_HEIGHT = 350;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
inlineVideo: {
|
||||
description: "Play videos without carousel modal",
|
||||
|
@ -33,15 +27,11 @@ export default definePlugin({
|
|||
|
||||
patches: [
|
||||
{
|
||||
find: ".oneByTwoLayoutThreeGrid",
|
||||
replacement: [{
|
||||
match: /mediaLayoutType:\i\.\i\.MOSAIC/,
|
||||
replace: "mediaLayoutType:'RESPONSIVE'",
|
||||
},
|
||||
{
|
||||
match: /null!==\(\i=\i\.get\(\i\)\)&&void 0!==\i\?\i:"INVALID"/,
|
||||
replace: '"INVALID"',
|
||||
}]
|
||||
find: "isGroupableMedia:function()",
|
||||
replacement: {
|
||||
match: /=>"IMAGE"===\i\|\|"VIDEO"===\i;/,
|
||||
replace: "=>false;"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "renderAttachments(",
|
||||
|
@ -51,52 +41,5 @@ export default definePlugin({
|
|||
replace: "$&$1.content_type?.startsWith('image/')&&"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "Messages.REMOVE_ATTACHMENT_TOOLTIP_TEXT",
|
||||
replacement: [{
|
||||
match: /\i===\i\.\i\.MOSAIC/,
|
||||
replace: "true"
|
||||
},
|
||||
{
|
||||
match: /\i!==\i\.\i\.MOSAIC/,
|
||||
replace: "false"
|
||||
}]
|
||||
},
|
||||
{
|
||||
find: ".messageAttachment,",
|
||||
replacement: {
|
||||
match: /\{width:\i,height:\i\}=(\i).*?(?=className:\i\(\)\(\i\.messageAttachment,)/,
|
||||
replace: "$&style:$self.style($1),"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
style({ width, height }) {
|
||||
if (!width || !height) return {};
|
||||
|
||||
if (width > MAX_WIDTH || height > MAX_HEIGHT) {
|
||||
if (width / height > MAX_WIDTH / MAX_HEIGHT) {
|
||||
height = Math.ceil(MAX_WIDTH / (width / height));
|
||||
width = MAX_WIDTH;
|
||||
} else {
|
||||
width = Math.ceil(MAX_HEIGHT * (width / height));
|
||||
height = MAX_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
maxWidth: width,
|
||||
width: "100%",
|
||||
aspectRatio: `${width} / ${height}`
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
start() {
|
||||
enableStyle(style);
|
||||
},
|
||||
|
||||
stop() {
|
||||
disableStyle(style);
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
[class^="nonMediaAttachmentsContainer_"] [class*="messageAttachment_"] {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
[class^="nonMediaAttachmentsContainer_"],
|
||||
[class^="nonMediaAttachmentItem_"]:has([class^="messageAttachment_"][style^="max-width"]) {
|
||||
width: 100%;
|
||||
}
|
|
@ -10,7 +10,7 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { React, Tooltip } from "@webpack/common";
|
||||
import { Tooltip } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
loop: {
|
||||
|
@ -28,9 +28,9 @@ export default definePlugin({
|
|||
settings,
|
||||
patches: [
|
||||
{
|
||||
find: ".nonMediaAttachment]",
|
||||
find: ".nonMediaMosaicItem]",
|
||||
replacement: {
|
||||
match: /\.nonMediaAttachment\]:!(\i).{0,10}children:\[(\S)/,
|
||||
match: /\.nonMediaMosaicItem\]:!(\i).{0,10}children:\[(\S)/,
|
||||
replace: "$&,$1&&$2&&$self.renderPiPButton(),"
|
||||
},
|
||||
},
|
||||
|
|
|
@ -94,7 +94,7 @@ export default definePlugin({
|
|||
find: "renderPrioritySpeaker",
|
||||
replacement: [
|
||||
{
|
||||
match: /renderName\(\).{0,100}speaking:.{50,100}jsx.{5,10}{/,
|
||||
match: /renderName\(\).{0,100}speaking:.{50,150}"div",{/,
|
||||
replace: "$&...$self.getVoiceProps(this.props),"
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue