Guest User

Untitled

a guest
Jan 26th, 2018
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getFileWithId(userId, docId, func){
  2.     fetch('https://vk.com/doc' + userId + '_' + docId).then(page => {
  3.         page.arrayBuffer().then(arr => {
  4.             var str = new TextDecoder('windows-1251').decode(arr);
  5.             func(isDocValid(str), docId);
  6.         });
  7.     });
  8. }
  9.  
  10. function isDocValid(text){
  11.     return text.indexOf('Файл был удалён') === -1 && text.indexOf('Этот документ был удалён из общего доступа.') === -1;
  12. }
  13.  
  14. function testUser(user, start, count){
  15.     var results = 0;
  16.  
  17.     for(var i = start; i <= start + count; i++){
  18.         getFileWithId(user, i, function(result, docId){
  19.             if(result){
  20.                 console.log(docId + ' положительный!');
  21.             }
  22.             results++;
  23.             if(results > count){
  24.                 console.log('Тест завершён.');
  25.             }
  26.         });
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment