Συζητήσεις » Αιτήματα Δημιουργίας
is it possible to press enter
yes
There you go:
let node = document.querySelector('YOUR_SELECTOR') || document.documentElement
let config = {
code: 'Enter',
key: 'Enter',
keyCode: 13,
which: 13,
target: node,
}
node.dispatchEvent(new KeyboardEvent('keydown', config))
node.dispatchEvent(new KeyboardEvent('keyup', config))
There you go:
let node = document.querySelector('YOUR_SELECTOR') || document.documentElement let config = { code: 'Enter', key: 'Enter', keyCode: 13, which: 13, target: node, } node.dispatchEvent(new KeyboardEvent('keydown', config)) node.dispatchEvent(new KeyboardEvent('keyup', config))
dear i think you misunderstood, alert don't have a selector, it's not a custom alertbox, regular alert(1)
yes
how do i do that? the native alert box not custom tho
i'd like to alert(1) then press enter using userscript, is it possible?
No, unless you will control the entire browser using node.js like so: https://chercher.tech/puppeteer/alerts-puppeteer
@ANGRY MAN, just created custom alter box :p Is it big problem??
@ANGRY MAN, just created custom alter box :p Is it big problem??
no, i wanna hang the process so i can alter a value in the source before it's rendered :D, i used blocking while loop sleep approach, it works..
but the alert one is easier if i could just get it out of their sight programmatically..
Oh, that's why you did it... Can't you just add to script meta values this block?:
// @run-at document-idle
The script will run when the document is fully loaded.
Oh, that's why you did it... Can't you just add to script meta values this block?:
// @run-at document-idle
The script will run when the document is fully loaded.
look a value is fetched because userscripts can't intercept http traffic i am trying to alter that value before it's set/assigned and
for that i have to be fast(document-start?) and hang the process(blocking sleep)
the script is 5 line of code, should i send it here?
@ANGRY MAN, yeah I think, if you will send code, then I'd probably be able to help you.
@ANGRY MAN, yeah I think, if you will send code, then I'd probably be able to help you.
sorry for the late reply, been very busy lately, here is the code
// ==UserScript== // @name ChatGPT_Plus // @version 0.1 // @description . // @run-at document-start // @match https://chat.openai.com/* // @grant none // ==/UserScript== setInterval(() =>{ window.__NEXT_DATA__.props.pageProps.accountStatusResponse.account_plan.is_paid_subscription_active = true },0)
reload the website a couple to see the effect,
i'd like to make sure everytime it's set to true and when you go to a conversation and come back to /chat the effect should still be there
can i achieve any of these, thanks a whole lot.
one more question if it's okay, can i actively check the size/length elements of a div
like first get the total size, if it increased addEventListener to the last added one?
trying to add "double click at chatgpt responses to have it copied to your clipboard"
Actually, there exists much easier solution, this is not good this in actual coding (in company's code, open-source project etc.), but if you want to achieve good performance just with this little user-script, that's what you can do:
Object.defineProperty(Object.prototype, 'is_paid_subscription_active', {
get() {
return true
}
})
To actively check div size, you must use MutationObserver
, like this:
let node = document.querySelector('div') // write your selector of div here
let obs = new MutationObserver(() => {
let width = node.offsetWidth
let height = node.offsetHeight
console.log('Width:', width, 'Height:', height) // logs width and height of element
})
obs.observe(node, {
childTree: true,
subtree: true,
attributes: true,
})
If the element does exist all time, then you can do something like this:
let selector = 'div' // write your selector of div here
let obs = new MutationObserver(() => {
let node = document.querySelector(selector)
if(node) {
let width = node.offsetWidth
let height = node.offsetHeight
console.log('Width:', width, 'Height:', height) // logs width and height of element
}
})
obs.observe(document.documentElement, {
childTree: true,
subtree: true,
attributes: true,
})
i'd like to alert(1) then press enter using userscript, is it possible?