userscripts
userscripts copied to clipboard
DuckDuckGPT safari
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
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:
// @grant GM_getValue
Remove line 29:
var GM_getValue = (() => window.GM_getValue)()
And finally, replace line 168 with:
var accessToken = await localStorage.getItem("accessToken")
...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: undefined is not a function (near '...GM_xmlhttpRequest...') asyncFunctionResume@[native code] @[native code] promiseReactionJobWithoutPromise@[native code] appendChild@[native code] injectJS@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:274:34 processJS@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:222:21 @safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:402:18
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
Sure, I could try
Is there any setup Iām missing?
I now get this error: undefined is not a function (near '...GM_xmlhttpRequest...') asyncFunctionResume@[native code] @[native code] promiseReactionJobWithoutPromise@[native code] appendChild@[native code] injectJS@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:274:34 processJS@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:222:21 @safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:402:18
Yeah it looks like none of the GM_ functions are supported by that extension & DuckDuckGPT uses these 5:
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_info
// @grant GM_xmlhttpRequest
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?
According to the other issue I should change it to GM. but then I get this error (will edit if anything changes):
ReferenceError {} column: 43 line: 87 message: "Can't find variable: GM_registerMenuCommand" sourceURL: "https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad" stack: "enableCommandMenu@https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad:87:43āµmain@https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad:54:26āµ@https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad:112:17āµ@https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad:179:3āµ@https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad:181:15āµglobal code@https://duckduckgo.com/?q=what+is+the+meaning+of+life&t=ipad:182:11āµappendChild@[native code]āµinjectJS@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:274:34āµprocessJS@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:222:21āµ@safari-web-extension://F0435466-F9A8-46C1-B498-8953D9410A63/content.js:402:18" __proto__: Object
I am one of the maintainers of the previously mentioned user script manager. The reason an error is thrown is because synchronous GM_
apis are not supported by the manager (outside of GM_info
and GM_xmlhttpRequest
). Only certain async
counter parts are supported - readme. The main difference in these api methods being sync
vs async
.
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 https://github.com/adamlui/userscripts/issues/10#issuecomment-1436006798 before applying @quoid's tweak? If so, I asked da bot and apparently the "nullish coalescing operator (??
), which is a relatively new feature introduced in ECMAScript 2020 [is not always supported]. Unfortunately, not all browsers support this feature yet, including some versions of Safari on iPad."
Can you try replacing them with the OR
operator?
var GM_setValue = (() => window.GM_setValue || GM.setValue)()
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)()
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 '<' onload@ @safari-web-extension://ED32EE2A-2F54-40AF-89E4-E1F764226C05/content.js:180:38 asyncFunctionResume@[native code] @safari-web-extension://ED32EE2A-2F54-40AF-89E4-E1F764226C05/content.js:156:59
Actually I just found out ChatGPT's been down forever...
So can you go back to using the ??'s, I think it might work when they're back up
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?
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)
No it didnāt work. After declaring the var right? Because line 27 isnāt the same for us