Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
35
src-tauri/src/inject/component.js
vendored
35
src-tauri/src/inject/component.js
vendored
@@ -136,8 +136,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
document.body.appendChild(m);
|
||||
setTimeout(function () {
|
||||
const d = 0.5;
|
||||
m.style.transition =
|
||||
'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
|
||||
m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
|
||||
m.style.opacity = '0';
|
||||
setTimeout(function () {
|
||||
document.body.removeChild(m);
|
||||
@@ -146,4 +145,36 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
window.pakeToast = pakeToast;
|
||||
|
||||
// chatgpt supports unlimited times of GPT4-Mobile
|
||||
if (window.location.hostname === 'chat.openai.com') {
|
||||
const originFetch = fetch;
|
||||
window.fetch = (url, options) => {
|
||||
return originFetch(url, options).then(async response => {
|
||||
if (url.indexOf('/backend-api/models') === -1) {
|
||||
return response;
|
||||
}
|
||||
const responseClone = response.clone();
|
||||
let res = await responseClone.json();
|
||||
res.models = res.models.map(m => {
|
||||
m.tags = m.tags.filter(t => {
|
||||
return t !== 'mobile';
|
||||
});
|
||||
if (m.slug === 'gpt-4-mobile') {
|
||||
res.categories.push({
|
||||
browsing_model: null,
|
||||
category: 'gpt_4',
|
||||
code_interpreter_model: null,
|
||||
default_model: 'gpt-4-mobile',
|
||||
human_category_name: 'GPT-4-Mobile',
|
||||
plugins_model: null,
|
||||
subscription_level: 'plus',
|
||||
});
|
||||
}
|
||||
return m;
|
||||
});
|
||||
return new Response(JSON.stringify(res), response);
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
62
src-tauri/src/inject/event.js
vendored
62
src-tauri/src/inject/event.js
vendored
@@ -82,14 +82,14 @@ async function invoke(cmd, args) {
|
||||
|
||||
// Judgment of file download.
|
||||
function isDownloadLink(url) {
|
||||
const fileExtensions = [
|
||||
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip',
|
||||
'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg',
|
||||
'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg',
|
||||
'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip'
|
||||
];
|
||||
const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i');
|
||||
return downloadLinkPattern.test(url);
|
||||
const fileExtensions = [
|
||||
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip',
|
||||
'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg',
|
||||
'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg',
|
||||
'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip',
|
||||
];
|
||||
const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i');
|
||||
return downloadLinkPattern.test(url);
|
||||
}
|
||||
|
||||
// No need to go to the download link.
|
||||
@@ -114,17 +114,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
domEl.addEventListener('mousedown', (e) => {
|
||||
e.preventDefault();
|
||||
if (e.buttons === 1 && e.detail !== 2) {
|
||||
appWindow.startDragging();
|
||||
appWindow.startDragging().then();
|
||||
}
|
||||
});
|
||||
|
||||
domEl.addEventListener('touchstart', () => {
|
||||
appWindow.startDragging();
|
||||
appWindow.startDragging().then();
|
||||
});
|
||||
|
||||
domEl.addEventListener('dblclick', () => {
|
||||
appWindow.isFullscreen().then((fullscreen) => {
|
||||
appWindow.setFullscreen(!fullscreen);
|
||||
appWindow.setFullscreen(!fullscreen).then();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -156,6 +156,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
let filename = anchorElement.download || getFilenameFromUrl(absoluteUrl);
|
||||
|
||||
// Process download links for Rust to handle.
|
||||
// If the download attribute is set, the download attribute is used as the file name.
|
||||
if (
|
||||
@@ -184,7 +185,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Rewrite the window.open function.
|
||||
const originalWindowOpen = window.open;
|
||||
window.open = function (url, name, specs) {
|
||||
window.open = function(url, name, specs) {
|
||||
// Apple login and google login
|
||||
if (name === 'AppleAuthentication') {
|
||||
//do nothing
|
||||
@@ -261,31 +262,34 @@ function convertBlobUrlToBinary(blobUrl) {
|
||||
});
|
||||
}
|
||||
|
||||
function downloadFromBlobUrl(blobUrl, filename) {
|
||||
const tauri = window.__TAURI__;
|
||||
convertBlobUrlToBinary(blobUrl).then((binary) => {
|
||||
console.log('binary', binary);
|
||||
tauri.fs.writeBinaryFile(filename, binary, {
|
||||
dir: tauri.fs.BaseDirectory.Download,
|
||||
}).then(() => {
|
||||
window.pakeToast('Download successful, saved to download directory~');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// detect blob download by createElement("a")
|
||||
function detectDownloadByCreateAnchor() {
|
||||
const createEle = document.createElement;
|
||||
const tauri = window.__TAURI__;
|
||||
document.createElement = (el) => {
|
||||
if (el !== "a") return createEle.call(document, el);
|
||||
if (el !== 'a') return createEle.call(document, el);
|
||||
const anchorEle = createEle.call(document, el);
|
||||
const anchorClick = anchorEle.click;
|
||||
|
||||
Object.defineProperties(anchorEle, {
|
||||
click: {
|
||||
get: () => {
|
||||
if (anchorEle.href && anchorEle.href.includes('blob:')) {
|
||||
const url = anchorEle.href;
|
||||
convertBlobUrlToBinary(url).then((binary) => {
|
||||
tauri.fs.writeBinaryFile(anchorEle.download || getFilenameFromUrl(url), binary, {
|
||||
dir: tauri.fs.BaseDirectory.Download,
|
||||
});
|
||||
});
|
||||
}
|
||||
return anchorClick.bind(anchorEle);
|
||||
}
|
||||
// use addEventListener to avoid overriding the original click event.
|
||||
anchorEle.addEventListener('click', () => {
|
||||
const url = anchorEle.href;
|
||||
if (window.blobToUrlCaches.has(url)) {
|
||||
downloadFromBlobUrl(url, anchorEle.download || getFilenameFromUrl(url));
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return anchorEle;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
23
src-tauri/src/inject/style.js
vendored
23
src-tauri/src/inject/style.js
vendored
@@ -1,4 +1,4 @@
|
||||
window.addEventListener('DOMContentLoaded', (_event) => {
|
||||
window.addEventListener('DOMContentLoaded', _event => {
|
||||
const css = `
|
||||
#page #footer-wrapper,
|
||||
.drawing-board .toolbar .toolbar-action,
|
||||
@@ -56,6 +56,10 @@ window.addEventListener('DOMContentLoaded', (_event) => {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
#__next > div.overflow-hidden.w-full.h-full .min-h-\\[20px\\].items-start.gap-4.whitespace-pre-wrap.break-words {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
#__next .PageWithSidebarLayout_mainSection__i1yOg {
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
@@ -312,7 +316,8 @@ window.addEventListener('DOMContentLoaded', (_event) => {
|
||||
}
|
||||
|
||||
@media (min-width:1024px){
|
||||
#__next .text-base.lg\\:max-w-xl, #__next form.stretch.lg\\:max-w-2xl {
|
||||
#__next .text-base.lg\\:max-w-xl, #__next form.stretch.lg\\:max-w-2xl,
|
||||
#__next > .w-full.h-full .lg\\:max-w-\\[38rem\\] {
|
||||
max-width: 44rem;
|
||||
}
|
||||
}
|
||||
@@ -327,6 +332,20 @@ window.addEventListener('DOMContentLoaded', (_event) => {
|
||||
#__next .overflow-hidden.w-full .max-w-full>.sticky.top-0 {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
#__next .overflow-hidden.w-full main.relative.h-full.w-full.flex-1{
|
||||
padding-bottom: 82px;
|
||||
}
|
||||
|
||||
#__next > div.overflow-hidden.w-full.h-full main.relative.h-full.w-full.flex-1 > .flex-1.overflow-hidden .h-32.md\\:h-48.flex-shrink-0{
|
||||
height: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width:565px){
|
||||
#__next .overflow-hidden.w-full main.relative.h-full.w-full.flex-1{
|
||||
padding-bottom: 98px;
|
||||
}
|
||||
}
|
||||
|
||||
#__next .prose ol li p {
|
||||
|
||||
Reference in New Issue
Block a user