-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DuckDuckGPT safari #10
Comments
Hey, I don't have a Mac so can't test support but can you try it using Tampermonkey @ https://www.tampermonkey.net/index.php?browser=safari&locale=en |
No, unfortunately I can’t. I was just wondering if it is something that would be easy to fix… |
How come? If you could it would probably work, GM_getValue is a function supported by userscript managers like Tampermonkey & Violentmonkey, the readme you linked is for a userscript editor only |
Because only userscripts supports ipad. It is not only an editor. Here is the popup in safari: https://github.com/quoid/userscripts#popup |
Ohh, well I asked da bot and it said: Do you know how to edit the code? Can you remove line 17:
Remove line 29:
And finally, replace line 168 with:
...and let me know if it works? |
Weird… the readme says it is supported but I’ll try and report back |
Ok then |
Actually you could try asking the extension author why the function wasn't supported on your iPad, and maybe provide them screenshots + link to my code |
I now get this error: |
Sure, I could try |
Is there any setup I’m missing? |
Yeah it looks like none of the GM_ functions are supported by that extension & DuckDuckGPT uses these 5:
|
Interesting… I wonder why they don’t work as here it claims it’s supported… |
Could it be that userscripts uses GM.[Item] instead of GM_[Item]? |
Opened an issue on the extension ^^ |
Maybe it has something to do with this? |
I'ma look at it tonight after I sleep (I was up all night) |
According to the other issue I should change it to GM. but then I get this error (will edit if anything changes): |
I am one of the maintainers of the previously mentioned user script manager. The reason an error is thrown is because synchronous I recommend the newer API methods, but thats obviously up to the user script author. If you'd like to support the newer API methods you could do something like: ...
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_info
// @grant GM_xmlhttpRequest
// @grant GM.deleteValue
// @grant GM.getValue
// @grant GM.setValue
// @grant GM.info
// @grant GM.xmlHttpRequest
...
var GM_setValue = (() => window.GM_setValue ?? GM.setValue)()
var GM_deleteValue = (() => window.GM_deleteValue ?? GM.deleteValue)()
var GM_info = (() => window.GM_info ?? GM.info)()
var GM_xmlhttpRequest = (() => window.GM_xmlhttpRequest ?? GM.xmlHttpRequest)()
var GM_getValue = (() => window.GM_getValue ?? GM.getValue)()
... |
Using just these updates makes it “work” but asks to log in even though I’m logged in… |
@Delamcode did you revert the edits in #10 (comment) before applying @quoid's tweak? If so, I asked da bot and apparently the "nullish coalescing operator ( Can you try replacing them with the
Also what version of Safari are you using, is it 10+? |
I am using safari 15. Yes, I did revert. I will try this. |
Now both methods stopped working… (Waiting for Response) with this error: JSON Parse error: Unrecognized token '<' |
The actual website is working fine for me, and I am logged in. Using ?? I still get the log in @ error, even though I’m logged in… |
Is it possible to console.log the id on my computer, and then hard code it on my ipad script? |
Probably, also you could try adding 'GM_deleteValue("accessToken")' after line 27, save, refresh search page, then remove the line, re-save, then refresh search page (just to clear it out) |
Where (and how) would you recommend doing the console.log? |
Can you try clearing the access token first see if that works? (I had to do this in incompatible browsers & it worked is why I didn't include them) |
Sure I might look into it if I have time! |
This is happening on macOS as well, not just iPadOS/iOS. You can just log the response in ...
onload: function(response) {
console.log('r', response)
...
}
... It's a {
readyState: 4
response: "<html>↵ <head>↵ <style global>body{font-family:Arial,Helvetica,sans-serif}.container{align-items:center;display:flex;flex-direction:colu…"
responseHeaders: "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r↵cache-control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0…"
responseText: "<html>↵ <head>↵ <style global>body{font-family:Arial,Helvetica,sans-serif}.container{align-items:center;display:flex;flex-direction:colu…"
responseType: ""
responseURL: "https://chat.openai.com/api/auth/session"
status: 403
statusText: "Forbidden"
timeout: 0
} If you add a check for that here: if (isBlockedbyCloudflare(response.responseText) || response.status === 403) {
alertLogin(); return
} The {
readyState: 4
response: "{}"
responseHeaders: "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r↵cf-cache-status: DYNAMIC\r↵cf-ray: 79d39c8a29d5e6e4-EWR\r↵content-length: 2…"
responseText: "{}"
responseType: ""
responseURL: "https://chat.openai.com/api/auth/session"
status: 200
statusText: "OK"
timeout: 0
withCredentials: false
} I am not entirely sure how this user script is supposed to function, but it seems you are expecting an access token from that response. I am not sure the context where the request is run has access to that token. I believe it's akin to making the request in an incognito tab, so I am not sure how one would get the actual token. I am not sure how to work around this. |
Hey @quoid the userscript forces user to visit login page if:
In Windows browsers when these 3 conditions do not exist, {"user":{"id":"user-9K0mEpF8oO9P6LsbYlV30ka6","name":"[email protected]","email":"[email protected]","image":"https://s.gravatar.com/avatar/3f6928f37e3fe9e016fed71c8c495608?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fad.png","picture":"https://s.gravatar.com/avatar/3f6928f37e3fe9e016fed71c8c495608?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fad.png","groups":[]},"expires":"2023-03-24T03:35:48.253Z","accessToken":"_______"} Without the 'accessToken' value from this expected object, requests to When I researched the 1st error earlier, I came across this answer: https://stackoverflow.com/a/59216403/2512339
Although no template literals are used, the answer does indicate something is different w/ how Apple handles requests (if that's of any help) |
@adamlui This has nothing to do with browsers or extensions. Your script will only work in certain "normal" situations because it lacks the necessary judgment (or error handling). For example you could check Your If these code is not gpt's work, perhaps you can let it tell you how to write it. (forgive my joke :D) |
And what is abnormal to you? (not sure why the quotes)
getAnswer() literally leads w/ a try-catch...
"Just a moment..." is the only situation where user is blocked by Cloudflare, so it is in fact very accurate. Why is it "unnecessary" for user to then be forced to clear Cloudflare checks? Have you ever used ChatGPT? (It doesn't work w/o passing it)
Of course. Who said
No offense is taken, it works in every browser except Safari, why not put your money where your mouth is & create a commit? |
@ACTCD Surely the big game you talk means you can fix it in 5 minutes max. So don't be scared now, back your mouth up 😉 (or no one will believe you) |
I should have been more clear. I got the userscript to pretty much work in Chrome/Violentmonkey on macOS. The issue I was seeing was specific to the Safari and even more specifically the background script of an extension. If I visit My guess is that the background script context is a completely isolated world in Safari, so it is treated like an incognito tab.
Speaking on the issue @Delamcode brings up, I am not entirely sure that is true. I can not be 100% sure because I only did some cursory exploration of the issue, but I think it has to do with the fact that background pages are an isolated environment. However, I do think that this is generally a good thing. I do not like the idea of background scripts being able to read auth tokens from users, for that I am not sure I would classify this as a bug, but perhaps a feature. I am curious how ViolentMonkey seems to accomplish this... Again, I would like to repeat that I did some hasty investigation so everything I say might not be accurate. |
Actually I said "Apple browser" but meant Safari & totally got what you meant! Based on your detailed clarification though, I found a few posts of Safari WebExtensions' background requests always failing but not in Chrome (just as you described, so you are onto something):
|
Which is weird, because I have even tried disabling all privacy settings in safari and this is still happening… Could it be that extensions cannot communicate with other sites other than the one that is being used? Apple does after all sandbox apps on ios… |
@Delamcode I don't think that is it. You can fetch data from other APIs/sites without issue (example pasted below). I think it is just that the background page is isolated. The call // ==UserScript==
// @name Example API call
// @description Example API call
// @match *://*.example.com/*
// @grant GM.xmlHttpRequest
// ==/UserScript==
(async () => {
GM.xmlHttpRequest({
method: "GET",
url: "https://jsonplaceholder.typicode.com/posts",
onloadend: e => {
let response = e.response;
try {
response = JSON.parse(response);
} catch (error) {
console.error("Failed to parse JSON");
}
console.log(response);
}
});
})(); |
@Delamcode can you try installing the latest version @ https://greasyfork.org/en/scripts/459849-duckduckgpt and turn on Proxy Mode: With this activated, requests are sent thru proxy using my own key so it should work |
First, I don’t think this is possible, as the Userscript manager for ios (afaik) doesn’t have any settings. Also, it is not even showing up in the duckduckgo website as a running script :(
…On 30 Mar 2023, 10:08 PM +0200, Adam Lui 刘展鹏 ***@***.***>, wrote:
@Delamcode can you try installing the latest version @ https://greasyfork.org/en/scripts/459849-duckduckgpt and turn on Proxy Mode:
With this activated, requests are sent thru proxy using my own key so it should work
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Delamcode Can you check safari console? Does an error like ' |
Nope. No errors. It seems like the script didn’t grant duckduckgo.com?
…On 31 Mar 2023, 7:17 AM +0200, Adam Lui 刘展鹏 ***@***.***>, wrote:
@Delamcode Can you check safari console? Does an error like 'GM_registerMenuCommand is not recognized' appear? If so I'm going to work on removing the menu and hard-code the proxy
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Delamcode Oh I changed it to |
@Delamcode install this: https://github.com/kudoai/duckduckgpt/raw/main/greasemonkey/duckduckgpt-ios.user.js it should work |
Tried that, and it showed up at least :) but error: ReferenceError {}
• column: 43
• line: 87
• message: "Can't find variable: GM_registerMenuCommand"
• sourceURL: "https://duckduckgo.com/?q=hello&t=ipad"
• ***@***.******@***.******@***.******@***.******@***.***://duckduckgo.com/?q=hello&t=ipad:181:15↵global ***@***.******@***.*** ***@***.******@***.******@***.***://872C2E0A-B9FE-4689-A249-28CC25A250F8/content.js:402:18"
• __proto__: Object
…On 31 Mar 2023, 8:02 AM +0200, Adam Lui 刘展鹏 ***@***.***>, wrote:
@Delamcode install this: https://github.com/kudoai/duckduckgpt/raw/main/greasemonkey/duckduckgpt-ios.user.js it should work
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Delamcode Can you try disabling this old script and install/enable the new one? ( |
It seems the problem was actually another script (for that error). Now I don’t have any errors, but it still doesn’t load…
…On 31 Mar 2023, 9:37 PM +0200, Adam Lui 刘展鹏 ***@***.***>, wrote:
@Delamcode GM_registerMenuCommand was removed from the updated script, so this error is coming from the old one (which always worked and showed on search results pages, just not on duckduckgo.com)
Can you try disabling this old script and install/enable the new one? (duckduckgpt-ios.user.js)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Delamcode what's the console showing for it? |
Nothing, weirdly…
…On 1 Apr 2023, 10:04 AM +0200, Adam Lui 刘展鹏 ***@***.***>, wrote:
@Delamcode what's the console showing for it?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Delamcode I figured it out, the proxy I was using was limited to my own IP but I fixed it in this update: https://github.com/kudoai/duckduckgpt/raw/main/greasemonkey/duckduckgpt-ios.user.js can you pls try? |
Still doesn’t work, and still no errors…
…On 1 Apr 2023, 11:54 AM +0200, Adam Lui 刘展鹏 ***@***.***>, wrote:
@Delamcode I figured it out, the proxy I was using was limited to my own IP but I fixed it in this update: https://github.com/kudoai/duckduckgpt/blob/main/greasemonkey/duckduckgpt-ios.user.js can you pls try?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Made CSS More Readable ↞ [auto-sync from `kudoai/duckduckgpt`]
Hey @Delamcode it works on Android now via Kiwi or Firefox which supports Tampermonkey, can you try intsalling Firefox for iOS then Tampermonkey for Firefox and confirm it works on iOS now too? |
Firefox for iOS unfortunately doesn't support extensions. Another browser called Orion does, but I wasn't able to get tampermonkey/violentmonkey working.
…On Dec 19, 2023 at 1:55 PM +0100, Adam Lui 刘展鹏 ***@***.***>, wrote:
Hey @Delamcode it works on Android now via Kiwi or Firefox which supports Tampermonkey, can you try intsalling Firefox for iOS then Tampermonkey for Firefox and confirm it works on iOS now too?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I know there is not official support, but using the userscripts extension I get this error: GM_getValue is not a function. (In 'GM_getValue("accessToken")', 'GM_getValue' is undefined). Do you have an idea of what is causing this? Here is the extension readme: https://github.com/quoid/userscripts
The text was updated successfully, but these errors were encountered: