Skip to content

Commit

Permalink
done widescreenDialogue
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoYingYo committed Aug 3, 2024
1 parent 8569195 commit 19e7a17
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion chatgpt/chatgpt-enhance/chatgpt-enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// @namespace Violentmonkey Scripts
// @match *://chat.openai.com/*
// @match *://chatgpt.com/*
// @version XiaoYing_2024.08.04.6
// @version XiaoYing_2024.08.04.7
// @grant GM_info
// @grant GM_getValue
// @grant GM_setValue
Expand Down Expand Up @@ -264,6 +264,29 @@ function initItemDeleteBtn() {
});
}

function widescreenDialogue() {
return new Promise(async (resolve) => {
if (globalVariable.get('initWidescreenDialogue') == 1 || $('body').find('style[id="widescreenDialogueCss]').length != 0) {
resolve();
return;
}
globalVariable.set('initWidescreenDialogue', 1);
try {
let sel = 'div[class^="items-center"]';
let Btn = await global_module.waitForElement(sel, null, null, 1000, -1);
Btn = Btn.eq(0);
let BtnParent = Btn;
for (let i = 0; i < 4; i++) {
BtnParent = $(BtnParent).parent().eq(0);
}
let cssClassName = BtnParent.attr('class').split(' ')[0];
let styleHtml = '.' + cssClassName + '{width:100%;max-width:100%;}';
$('body').append('<style id="widescreenDialogueCss">' + styleHtml + '</style>');
} catch (e) {}
resolve();
});
}

var HookFun = new Map();
HookFun.set('/backend-api/conversation', function (req, res, Text, period) {
if (period === 'preload') {
Expand Down Expand Up @@ -292,6 +315,9 @@ HookFun.set('/backend-api/conversation', function (req, res, Text, period) {
resolve(null);
return;
}
setTimeout(async () => {
await widescreenDialogue();
}, 100);
resolve(null);
});
});
Expand Down Expand Up @@ -357,6 +383,7 @@ ajaxHooker.hook(handleResponse);

$.onurlchange(function () {
setTimeout(async () => {
await widescreenDialogue();
await purify();
}, 1000);
});

0 comments on commit 19e7a17

Please sign in to comment.