In Slack, is it possible to write a chrome script that automatically adds reactions to messages without using a complicated solution such as Postman via the API? I have tried using the keydown event, but it was not successful. Is there an alternative method for simulating the Ctrl+Shift+\ shortcut and artificially clicking an icon?
Related
I am trying to programmatically click a button in a web page using the command
document.getElementsByName("versionFile")[0].click()
while this command works fine in the developer tool console (opens the file selector) i am not able to execute this in script because it gives me a error saying "File chooser dialog can only be shown with a user activation" highlighting the click() function
Can anyone hep me out with this.
Most modern browsers restrict the JavaScript interactions not started by the user, to avoid annoying pages and make XSS a bit more difficult.
If you are using a web-scraping library like puppeteer, you should interact with the page using it's API (using page.click for example), not by injecting JavaScript on the page.
If that is not a option, you need to find the callback function that the button fires, and bypass the element.click() method.
I'm developing cross-browser extension using WebExtensions API. It's focused on monitoring some HTTP request and blocking potentially malicious ones. I need to get user input for each blocked host (because it could have been falsely blocked and user might want to unblock it right away). Originally I wanted to use popup, but then I found out, that popups are only allowed to be thrown up in User Action event handler, which is a problem, I need to to that independently on the user's action. After that I found second option - the Chrome's notification API. But again, found out, that Firefox does not implement buttons in notifitacions (even though Chrome does). OnClicked event is supported for notification, but that's not enough (mainly because of users accidentally clicking on the notification to close it).
TL;DR - Looking for a way to alert/notify user and get the input from him by clicking on one of two presented buttons. Popups and Notifications does not seem like sufficient way.
Can you suggest ways to implement desired behaviour?
Possible solutions:
1) Injecting content script that implements popup window and communicates via messages with bacgkround script.
2) Simulating animation of extension's icon to draw user's attention.
I am making a web app similar to instagram and i want to detect and call a function whenever a user takes the screenshot, is their any way to implement this with javascript?
Currently, there is no way to handle a screenshot event through javascript. The screenshot functionality of phones simply has no connection to the browser.
I'm writing a chrome extension which will perform some actions when a system notification pops up. Specifically, I want to close them.
For example: the "Restore pages?" notification:
My manifest file has nothing particularly interesting, here is my event page:
function anyAlarmHandler (Alarm anyAlarm) {
// For now, just clear any alarm when one pops up.
chrome.alarms.clear(anyAlarm);
}
chrome.alarms.onAlarm.addListener(anyAlarmHandler);
But it doesn't clear the system notification as expected.
I suspect that I'm listening for the wrong event, that system notifications are not actually considered an alarm. But the 'notifications' API doesn't have anything regarding catching notifications.
I've looked at this question regarding catching notifications, which might work, but it doesn't help with the following:
I need to catch notifications created by the browser itself, not another extension (this might not matter, I'm not sure)
I need to modify that notification. Change the text, close it, whatever.
I've tried using the code in the link above and just popping some dialogue box when a notification happens (to test if that solution works for detecting browser notifications), but even that didn't work. I'm hoping that I'm just missing some method/event listener in some API, but I can't seem to find it anywhere. Any help is appreciated.
You cannot detect, or override, any of the Chrome's own UI popups like this.
Only another native app could potentially interact with them (e.g. simulate a click).
Short of patching Chrome (in-memory or on disk), you won't be able to change the wording.
I am currently trying to manually develop an unsaved changes warning in our JSF-based Webapplication. Sadly our customer does not like the styling of the default warning displayed via an alert() after using the onbeforeunload event and requires us to develop a similar mechanism on our own.
I was thinking of using the way described here to prevent the onbeforeunload event from displaying the alert() and simply showing my own modal panel. I just can't figure out how to make the "Yes" (yes, I want to leave this page and lose all unsaved changes) button work. The button should basically resend the request which lead to the onbeforeunload event which could have been a HTTP Request as well as an Ajax Request. How would one do that via JS?
Thank you :)
Cheers
//edit: It needs to work in IE9 as well as Chrome 38