I am using web3 for users to sign some random string from web application. I give user string, he/she signs it after Metamask dialog's "Sign" button. but there is a problem when i want user to sign about 1000 random strings separately. there are unhandled amount of confirmation dialogs. what is the solution?
Signing a message is a privileged action, and MetaMask is correct to prompt the user every time they perform this action.
A signed message can be anything from a valid transaction to a "undeniable" message from the user. Any user signing messages which are being generated by a program should be fully aware of what exactly they are signing.
In your situation, it may make sense to not use MetaMask, but to use the private key of the Ethereum account you want to sign messages with to programmatically create these signed messages without any user input.
However, this would require that your users trust your application with their private key, and that would probably not be the best idea either... It might be best then to concatenate the messages in question and have the user sign a single longer message if possible.
The only way to deal with this situation is to use unlockAccount first, so that you unlock the account and you already have a signing mechanism and no need to use metamask sign. Just unlock it first and then deal with it.
Have you taken a look at Fortmatic yet? It seems to be a pretty good alternative to MetaMask and may resolve the problem you are having.
They seem to provide both "personal_sign" and "eth_signTypedData" functionalities.
Why do you need to sign 1000 string separately?
One possibility is to build a merkle tree from the strings and only sign the merkle root hash.
To validate an string you send the signature, the string and the merkle tree proof.