OK so i currently play a game that has a random "bot-check" pop up in
the tab in the pop up it has a "OK" and "cancel" button and I'm trying
to find or make a grease monkey script to auto click "cancel" when it
pop's up and since its random it needs to be a always on type script
the prompt always shows up in the same x and y co-ordinates and button 1 is always OK and button 2 is always cancel hitting escape works just the same as hitting cancel
ive tried google and i cant find anything
// #require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
$(".popup").bind('show',function(){
$(this).hide();
});
may work, depends on the popup type.
if it doesn't work, try this:
// #require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
$(".popup").bind('show',function(){
$(".popup .cancel).trigger("click");
});
[if JQuery wasn't successfully installed in your script previously, you'll need to uninstall your script and reinstall it]
edit: for imitation of pressing escape, use
// #require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
var esc = $.Event("keydown", {
keyCode: 27
});
$(".popup").bind('show',function(){
$('body').trigger(esc);
});
Related
I have created a file import functionality using nodejs,express and socket.io. Everything is working fine but now I have to implement a feature in which , user clicks on a button and on click of this button, I want to cancel/stop the execution of code (wherever the control is at that moment, should not execute further). I have tried return, res.end(), res.send(), eventEmitter, throw error etc but script processing is not getting stopped. On using process.exit, code execution stops but it shutdown for all users no matter from where they are operating(i.e if 5 users are using import feature, code executions stops for all five users). Can anybody have any other suggestions?
You can make an interval checking the if the state of the button (button click should change a flag) once you check the flag you can resolve your function ( the function should be a promise) and then it will stop the execution of the code example:
let flag = false
function test(){
return new Promise((res, rej)=>{
let interval = setInterval(()=>{
if (flag){
res();
}
},1000)
/*rest of code goes here*/
})
}
I use the ace editor with the vim keybindings on my site. Whenever someone goes into normal mode and types a command, it shows up in a dialog at the bottom. I defined a function like so:
ace.config.loadModule("ace/keyboard/vim", m => {
m.CodeMirror.Vim.defineEx("write", "w", () => submitForm())
})
The neat thing is, whenever that function errors, it shows the error in another dialog. My question is, is this feature exposed to users? Can I use that dialog to show messages like the editor does when the function errors? Here's a screenshot to show an example:
Typing a command -
Error pops up (another dialog in front of the one that I use to type the command) -
there is no documented api for this, but judging by
https://github.com/ajaxorg/ace/blob/v1.4.9/lib/ace/keyboard/vim.js#L4983, it should be possible to use the following
editor.state.cm.openNotification(domNodeOrHtmlString, {bottom: true, duration: 5000})
to create the dom node you can use the buildDom function from ace.
var domNode = ace.require("ace/lib/dom").buildDom(["span", {style: "color:red"}, "xxxxx"])
I am using the https://github.com/mikaelbr/node-notifier package to show notifications in shell.
This is my code:
var notifier = require('node-notifier');
var path = require('path');
notifier.notify({
title: 'My awesome title',
message: 'Hello from node, Mr. User!',
icon: path.join(__dirname, 'coulson.jpg'), // absolute path (not balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // wait with callback until user action is taken on notification
}, function (err, response) {
// response is response from notification
});
notifier.on('click', function (notifierObject, options) {
// Happens if `wait: true` and user clicks notification
});
notifier.on('timeout', function (notifierObject, options) {
// Happens if `wait: true` and notification closes
});
The notification comes like this:
As you can see a terminal icon is coming before the name.
Can you help me how to remove that icon?
It is known issue with node-notifier.
From issue #71:
mikaelbr:
No, I'm afraid that's how the notification work, as it's the terminal that initiates the message. The only way to avoid this is to use your custom terminal-notifier where the Terminal icon is swapped for your own. It's not a big task, and you can easily set customPath for notification center reporter.
kurisubrooks:
This happens because of the way notifications in OS X work. The notification will show the referring app icon, and because we're using terminal-notifier to push notifications, we have the icon of terminal-notifier.
To work around this, you'll need to compile terminal-notifier with your own app.icns. Download the source, change out the AppIcon bundle with your own in Xcode, recompile terminal-notifier and pop it into node-notifier. (/node-notifier/vendor/terminal-notifier.app)
Now that you have your own terminal-notifier inside node-notifier, remove all the icon references from your OS X Notification Center code, and run the notification as if it has no icon. If the old app icon is showing in your notifications, you need to clear your icon cache. (Google how to do this)
Another valuable comment from mikaelb:
That's correct. But keep in mind, node-notifier uses a fork of terminal-notifier (github.com/mikaelbr/terminal-notifier) to add option to wait for notification to finish, so this should be used to add your own icon. A easy way to do it is to copy/paste from the vendor-folder and use customPath to point to your own vendor.
I tried #Aleksandr M's steps but it didn't seem to work for me. Maybe I didn't understand the steps well enough. Here's how it worked for me.
I cloned https://github.com/mikaelbr/terminal-notifier . Then opened the project with xcode and deleted the Terminal.icns file and replaced it with my custom icon Myicon.icns.
Then edited terminal-notifier/Terminal Notifier/Terminal Notifier-Info.plist by setting the key icon file to Myicon.
After doing this, simply building the project did NOT work. I had to change the values of the build version and build identifier (any new value would do) see this.
Afterwards I just built the project with xcode and then copied the built .app file (you can find it by clicking the Products directory of the project from xcode Products > right click the file > show in finder) to my electron project
e.g your final path may look like this. electron-project/vendor/terminal-notifier.app.
Then I set customPath as #Aleksandr M suggested.
Here's what mine looked like
var notifier = new NotificationCenter({
customPath: 'vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier'
});
And THEN it worked! 🙂
This solved my problem and you only need to have your icns file ready:
run this command in terminal after downloading :customise-terminal-notifier
** path/customise-terminal-notifier-master/customise-terminal-notifier -i path/Terminal.icns -b com.bundle.identifier
I'm developing a Chrome extension and have a strange problem with icon change on-the-fly.
In my popup.html I have a button by clicking on which I want to change the icon of the extension in the browser. E.g. from colored one to black and white (when application is inactive).
So the function which is responsible for this:
function toggleActivated(){
localStorage.isActive = toBool(localStorage.isActive) ? false : true;
$('#activate-disactivate span').text(toBool(localStorage.isActive) == false ? 'Включить' : 'Выключить');
chrome.browserAction.setIcon({path: toBool(localStorage.isActive) ? '48.png' : '48_bw.png'});
//window.close();
}
But the problem is that I want to close popup after the icon changed. If I use the window.close() at the end - then the icon is not changed, but if it is commented out - then the icon is changed fine.
Why is there a conflict between chrome.browserAction.setIcon() and window.close()?
It sounds like chrome.browserAction.setIcon is getting fired asynchronously but the popup is getting closed before it finishes. You could try adding a 500ms setTimeout before closing.
You should also file a bug report at new.crbug.com.
I know this is old, but I was having the same problem and abraham was right when he said that chrome.browserAction.setIcon was being called asynchronously. But I don't think that setting a timeout is the best answer.
If you check the setIcon documentation you can see that this method takes a function callback as parameter. That's where you should call window.close(). Like this:
chrome.browserAction.setIcon({ path: icon_path }, function() {
window.close();
});
UPDATE:
As niraj.nijju pointed in the comment below, you can pass a tabId param to the setIcon function to limit the scope of the change.
I have a webpage that has an onbeforeunload script that prompts the user when they take an action that would navigate away from the current page.
How do I interact with this popup using Watir? My current approach looks like this:
$ie.link(:text, 'Dashboard').click_no_wait
hwnd = $ie.enabled_popup(10)
assert(hwnd, 'The expected \'leave this page?\' popup was not shown')
win = WinClicker.new
win.makeWindowActive(hwnd)
win.clickWindowsButton_hwnd(hwnd, "OK")
The problem is that if I use "click no wait" the popup is not created, and the test times out. If I use "click" then the popup is created, but the test hangs after it opens.
Any suggestions?
Do you want to assert dialog message?
I try your code, but could not find solution.
This is to try to catch dialog then when popup,get msg while 5sec. polling per 1sec.
$ie.link(:text, 'Dashboard').click_no_wait
#autoit = WIN32OLE.new('AutoItX3.Control')
5.times do
if #autoit.WinWait('Windows Internet Explorer','',1)==1 then
#autoit.WinActivate('Windows Internet Explorer',"")
#dialog_text = #autoit.WinGetText('Windows Internet Explorer',"")
dialog_pop = "YES"
break
else
sleep(1)
dialog_pop = "NO"
end
end
This should do the trick closing this alert:
browser.alert.ok
See the Watir docs here.