1. Go / Говнокод #28193

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    package main
     
    func main() {
        var str = "Hello World"
        var length = len([]rune(str))
        println("Length of the string is :", length)
    }

    String Length in Golang

    To get the length of a String in Go programming, convert the string to array of runes, and pass this array to len() function.

    3_dar, 26 Мая 2022

    Комментарии (93)
  2. C++ / Говнокод #28192

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #include <iostream>
    
    int main() {
        const char* pituh = {};
        std::cout << pituh;
    }

    Нахуя?

    3_dar, 26 Мая 2022

    Комментарии (7)
  3. Куча / Говнокод #28191

    −1

    1. 1
    Электрика / электроника #6

    #1: https://govnokod.ru/25437 https://govnokod.xyz/_25437
    #2: https://govnokod.ru/25820 https://govnokod.xyz/_25820
    #3: https://govnokod.ru/26570 https://govnokod.xyz/_26570
    #4: https://govnokod.ru/27622 https://govnokod.xyz/_27622
    #5: https://govnokod.ru/27741 https://govnokod.xyz/_27741

    nepeKamHblu_nemyx, 26 Мая 2022

    Комментарии (450)
  4. Куча / Говнокод #28190

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    with Ada.Unchecked_Conversion;
    with Interfaces.C;
    with System.Address_To_Access_Conversions;
    with System.Address_Operations; use System.Address_Operations;
    
    with VGA_Console; use VGA_Console;
    
    procedure Crash (Source_Location : System.Address; Line : Integer) is
       package C renames Interfaces.C;
    
       --  Get the length of the C NULL terminated string.
       function Length (Source_Location : System.Address) return C.size_t is
          use type C.size_t;
    
          function Convert is new Ada.Unchecked_Conversion (Source => C.size_t,
                                                            Target => System.Address);
    
          package To_Char is new System.Address_To_Access_Conversions (Object => C.char);
    
          Count : C.size_t               := 0;
          Char  : To_Char.Object_Pointer := To_Char.To_Pointer (AddA (Source_Location, Convert (Count)));
       begin
          while C.char'Pos (Char.all) /= 0 loop
             Count := Count + 1;
             Char  := To_Char.To_Pointer (AddA (Source_Location, Convert (Count)));
          end loop;
    
          return Count;
       end Length;
    
       --  This is really ugly, just to convert an address pointing to a C NULL terminated string to an Ada String!
       Source_Length : constant C.size_t := Length (Source_Location);
    
       type Source_Chars is new C.char_array (0 .. Source_Length);
    
       C_Str         : Source_Chars with
         Address => Source_Location;
       pragma Import (Convention => Ada, Entity => C_Str);
       Source_Str    : constant String := C.To_Ada (C.char_array (C_Str));
    begin
       Put (Str        => "** Kernel crashed at: " & Source_Str & ":" & Integer'Image (Line) & " **",
            X          => 1,
            Y          => 10,
            Foreground => White,
            Background => Red);
    
       --  TODO: Dump registers.
    
       Hang : loop
          null;
       end loop Hang;
    end Crash;

    3_dar, 25 Мая 2022

    Комментарии (13)
  5. Python / Говнокод #28188

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    try:
        self._api = caller(self.url)
    except ValueError as e:
        logging.error(f"Не удалось инициализировать класс API: ({str(e)})")
        raise ValueError(str(e))

    hvx, 24 Мая 2022

    Комментарии (43)
  6. C++ / Говнокод #28187

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    #define _CRT_SECURE_NO_WARNINGS
    #pragma comment(lib, "ntdll.lib")
    
    #include <Windows.h>
    #include <string>
    
    #define FLG_HEAP_ENABLE_TAIL_CHECK 0x10
    #define FLG_HEAP_ENABLE_FREE_CHECK 0x20
    #define FLG_HEAP_VALIDATE_PARAMETERS 0x40
    #define NT_GLOBAL_FLAG_DEBUGGED (FLG_HEAP_ENABLE_TAIL_CHECK | FLG_HEAP_ENABLE_FREE_CHECK | FLG_HEAP_VALIDATE_PARAMETERS)
    
    typedef NTSTATUS(NTAPI* pfnNtSetInformationThread)(
    	_In_ HANDLE	ThreadHandle,
    	_In_ ULONG ThreadInformationClass,
    	_In_ PVOID ThreadInformation,
    	_In_ ULONG ThreadInformationLenght);
    
    const ULONG ThreadHideFromDebugger = 0x11;
    
    typedef NTSTATUS(NTAPI* pfnNtQueryInformationProcess)(
    	_In_ HANDLE	ProcessHandle,
    	_In_ ULONG ProcessInformationClass,
    	_In_ PVOID ProcessInformation,
    	_In_ ULONG ProcessInformationLenght,
    	_Out_opt_ PULONG ReturnLenght);
    
    const UINT ProcessDebugPort = 7;
    
    void HideFromDebugger()
    {
    	HMODULE hNtDll = LoadLibrary("ntdll.dll");
    
    	if (!hNtDll)
    		throw std::exception("can't load kernel");
    
    	pfnNtSetInformationThread NtSetInformatioThread = (pfnNtSetInformationThread)
    		GetProcAddress(hNtDll, "NtSetInformationThread");
    
    	NTSTATUS status = NtSetInformatioThread(GetCurrentThread(), ThreadHideFromDebugger, NULL, NULL);
    }
    
    PVOID GetPEB()
    {
    	return (PVOID)__readfsword(0x0C * sizeof(PVOID));
    }
    
    int main()
    {
    	pfnNtQueryInformationProcess NtQueryInformationProcess = nullptr;
    	NTSTATUS status;
    	DWORD IsDebuggerPresent = 0;
    	HMODULE hNtDll = LoadLibrary("ntdll.dll");
    
    	if (!hNtDll)
    		throw std::exception("can't load kernel");
    	
    	NtQueryInformationProcess = (pfnNtQueryInformationProcess)GetProcAddress(hNtDll, "NtQueryInformationProcess");
    	void HideFromDebugger();
    
    	while (true)
    	{
    		PVOID pPEB = GetPEB();
    		DWORD offsetNtGlobalFlag = 0x68;
    		DWORD NtGlobalFlag = (DWORD)((PBYTE)pPEB + offsetNtGlobalFlag);
    
    		NTSTATUS stat = NtQueryInformationProcess(GetCurrentProcess(), ProcessDebugPort,
    			&IsDebuggerPresent, sizeof(DWORD), NULL);
    
    		if ((NtGlobalFlag & NT_GLOBAL_FLAG_DEBUGGED) || (stat == 0x00000000 && IsDebuggerPresent != 0))
    		{
    			MessageBox(NULL, "Close your fucking debuger!", "FUCK YOU", MB_OK);
    			return -1;
    		}
    	}
    
    	return 0;
    }

    PVOID, 23 Мая 2022

    Комментарии (26)
  7. Куча / Говнокод #28186

    −4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    Бесконечный оффтоп имени Борманда #6
    
                                                                         .^777!~^~^                     
                                                                        :~777!!!^~~:                    
                                                                      .^!?7!!!!!~^~~.                   
                                                                      ^!7777!777~^^~^.                  
                                                                     ^~77~77!!!!~^^~!^.                 
                                                                    :!!!!^~^:^~!!~^^~!^                 
                                                                   .!!!~:::..:~!7!^^~!~:                
                                                    ..::^^^^^^^^^^~!!~7!^:.....^!!~~~~!~                
                                              ...:^^~!!!!!!!!!!!!77!!~!~......:~!!~^~~!~:               
                                          .:^^~!!!!7777!!~~~~~~~~!!~!!!~::.....^~7!~^~~!~.              
    ~~~~^^::...............::::::::....:^~~!!7!!!!!!!!!!!~~~~~!!!~~~!7!~~^^::^:.^!!!~~~!7^.             
    .~!!!!!!!~~~~~~~~~~~~~~!!!!!!!~!!7!!!!!!!!!~~~~~~~~~~~~~~~!!~!!~!!!!~~~~~~~^~!!~~~~!7!^.            
      :~!~!!7???7!~~~~~~~~~~~~~~~!77!!!!~!!!~~~!!~!!!!!!!!!!!!!!!!!!!!777!!~~~~!7!~~!!!7!!!~:           
       .:~!~~77?JJJ7!!~~~~!!~~~!77!~~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!77!!!!!!!!!!!!^.         
         :~!!!!!!!7?JJ?7!!~~~!77!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!7!!!!!!!!!!!!!!^.        
           :~!~~!7!^~!7JJJ?777!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!7J?7!!!~!!!!!!!!!~~!!!!!!!!!!!!7^.       
            .^!!!!~..::^~!?J?!!!!!!!!!!77!!!!!!!!!!!!~~~~~^^^^^^7?!~~~^^^!!!~~!!^^~!~!!7?7!!!!!!^       
              .^~~~~:..^~~!!!!!!!!!!!777!!!!!~~~^^^^:^^^^^~~?YJ!7J5Y?!~~^~!~^^~~^:^!!~!!7J?7!!!7~:      
                 .:~:..:~!!!!~~!!!!777!~~^^:::^^^~~!!!!!!!!JPBGY7?YPGY77?!!!~^^!~^:~?!!!7YYJ7!!!7!.     
                   .::^~~~~~^^~~!!7!^::::^^~~!!!7!!7?!!!!!7PGP5P??JJ5GY??J7!!!~!!~~~7?7!!755?7!!7!~.    
                     :~~:^:::::^^~^^^^~!!!!!!!7??!!??!!!7?JPGYJPYJ??JPGYJPJ7!!!!!!!!7J?7!!YPY?7!!77^.   
                    .:^::::^^::~!!!!7??7!!7J7?557!?JJ!!7?YPGPYJ5P5Y??JPGPPPJ777!!7777YJ7!!?5PJ?7777?^.  
                   :^~~~~~!!!!777!!JJ?!!!?YPYPPJ?755?!!?5GGGPYJ5GGY???JPGGGPY7?7!?J77YJ7777YGP5J77777~. 
                 .^!7!!!!!!!7?77!7JY?7?!?5GPGGPJJ5G5?7!JPGGBP5JJP5J7777JPGYP5J?7!JY7?5Y777!JPGG5J77JJ?!:
                :~7!7!!!!!!7?77!7J5??J775GGGGGP5YPG5J?75GGBBY?7?55YY555PGBYYPPJ7!Y5?J5Y7777?J5GG5?7YJJ?7
              .^!777?7!!!!7?77!7JP?JY?7YGGGG5Y5P5GG5JYJPGGGGJ?YGG5JY#&&&&&#GPP577YP5PPY7777?J??PGY77YY?7
            :~7777??777777??7?7YPJ?5J7JPGGG5JYPGGGPYY55GP55PJ?5GJ^.^G&&&##&GGBG??YGGGGY777!?YY~JGPY7JYJJ
         .:!777!~~7777777???J7JP57PY7?PBGGPYY5PPGG5JYGGG5??5J??!!5GG#&@&BP#J?Y57J5GGGGY77777JP7?5GPJ7JYJ
       .^~!!^:: :!777777!???J755JJGJ7JGBG5???JJYGGY?JGBGY77?77!:.?B#BGBBG57^.^?7YPGGGGY7777!?555PGGPJ?JJ
       .:.     .~J5?7777JJ???JPYJPP??5GG5Y5PGGGGGGY??JGGJ77~~^:...^JPGB##GJ^.:775GGGGGY777777JPGGGGGPJ?Y
               !Y5Y7!!7?5Y77J5G5YG5?JP55PGP?P#&&BBY?7?Y5J7~:........:!?J?!^::~7JPGGGGPJ777777?PGGGGGG5JJ
              .Y5?77J??P5J77?PGP5G5?YPJ?GP?~?B&&#BJ~^!^!!~..................^77?5GGGG5?77777775GGGGGGG5?
              ~Y?~775PPGP?!7JGGGGGPJ5P?7GG5B#&&&##?:.......................:!7!~YGGG5Y?7777777YPGGGGGGPY
              !!~!7JPP5P?7!?5GBBBBG5PG5?YY?7PBBGG?~:.......................!!^:!5GGP55J7777777?5GGGGGGGP
              ~:^!755?!Y777?PGGBBBGGGGGPJ~..:~J55?7^......................:^:.:JPGPJ55J777777775GGGGGGGG
              . .~JG7:^??77?GBGGBBGGBGGGGJ^...:~!~:...........................:5G5??55J777777775GGBGGGGG
                 ^55^ :??7!?GBGGGBGGBBGGGGY^..........:^^^^^::...............:!PY7~?5Y?77777777YGGGGGGGG
                 :7!. :??77JGBGGGGGGGBGGGGGY:..........:^^^^::...............^YJ~~7?YY?77777777YGGGGGGGG
                  ..  .!J7?5GBGGGGGGGGGGGGGG?:................::::^^........:!7~!???J?7777777775GGGGGGGG
                       :7??YGBGGGGGGGGGGGGGGG?^............:^^^^^^:.........:~!?????J?77777777?5GGBGGGGG
                       .??J5GGGGGGGGGGGGGGGGGB57:...........::::::.........^!???????J?77777777?5GGBGGGGG
                     .^!77?5GGGGGGGGGGGGBGGGGBBG5?~:...........::.......:~7?????????J777777777?5GGBBGGGG
                   .^!77777JGBGGGGGGGGGGGGGGBBGGGGGPJ7~::............:^!?JJ????????JJ777777777JPGGGGGBGG
                 .^!777777J5GGGGGGGGGGGGGGGBBGGGGBBBBBBG5J?!~^:...:^!?JJJ????????J5G??777777775PGGGGGGGG
              .:~7777777?5PGGGGGGGGGGGGGGGGBGGGGGBBBBB###BBBBGP5YJJYYYJ????????YPB#GJ77777777?PGGGGGGGGB
            .^!7777777?YPGGGGGGGGGGGGGGGGGBGGGGGBBBBBBBBBBBG####&B5JJ???????JPG###B5J7777777?JPGGGGGGGGG
          :~!????777?YPGGGGGGGGGGGGGGGGGGGGGGGGGBBBBBB#BBBBPB###&#P?????????P#####BJ?77777!?YYPGGGBGGGGG

    Борманд, вернись.

    #1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
    #2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
    #3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
    #4: https://govnokod.ru/26838 https://govnokod.xyz/_26838
    #5: https://govnokod.ru/27625 https://govnokod.xyz/_27625

    kcalbCube, 23 Мая 2022

    Комментарии (27)
  8. Си / Говнокод #28185

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    #include <stdio.h> //Нужная библиотека, как обычно;
    
    int main(){ //Типа начало программы;
        FILE *in,*out; //Входной и выходной файлы;
        unsigned long int h,i; //Высота изображения и итератор цикла;
        unsigned char px,s; //Прочитанный пиксель и насчитанный сэмпл аудио;
        in=fopen("1.bmp","rb"); //Открываем файл на чтение;
        out=fopen("1.pcm","wb"); //Открываем файл на запись;
        fseek(in,22,SEEK_SET); //Позиционируемся в то место заголовка, где записана высота изображения
        fread(&h,4,1,in); //Считываем высоту изображения (4 байта);
        for(i=0;i<h;i++){ //Цикл - пробег по строкам;
            fseek(in,0x436+i*256,SEEK_SET); //Позиционируемся на начало i-ой строки
            s=0; //Инициализируем счётчик (значение сэмпла);
            do{ //Подсчёт нечёрных пикселей;
                fread(&px,1,1,in); //Считываем цвет пикселя;
                s+=1; //Увеличиваем счётчик на единицу;
            }while(px); //И так, пока не встретится чёрный пиксель;
            fwrite(&s,1,1,out); //Записываем получившийся результат в выходной файл;
        }
        fclose(in); //Закрываем входной файл;
        fclose(out); //Закрываем выходной файл;
        return 0; //Типа конец программы;
    }

    https://habr.com/ru/post/419527/

    kcalbCube, 23 Мая 2022

    Комментарии (0)
  9. JavaScript / Говнокод #28183

    −9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    const puppeteer = require('puppeteer-core');
    const fs = require('fs');
    const getCurrentLine = require('get-current-line').default;
    const { execFileSync } = require('child_process');
    
    const data = fs.readFileSync('aviso.bz.cookies.json');
    const cookies = JSON.parse(data.toString());
    
    function randomInteger(min, max) {
      let rand = min - 0.5 + Math.random() * (max - min + 1);
      return Math.round(rand);
    }
    
    function delay(time) {
       return new Promise(function(resolve) {
           setTimeout(resolve, time*1000)
       });
    }
    
    function delay2(time) {
       return new Promise(function(resolve) {
           setTimeout(resolve, time)
       });
    }
    
    let ext = '/home/user/aviso/extensions/1.42.4_0';
    
    (async () => {
      const browser = await puppeteer.launch({
        headless: false,
        defaultViewport: null,
        executablePath: '/usr/bin/chromium',
    devtools: false,
        args: [
    '--start-maximized',
    //'--user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36"',
    //`--disable-extensions-except=${ext}`,
    //`--load-extension=${ext}`
     ]
      });
    
      const page = await browser.newPage();
      await page.setDefaultNavigationTimeout(0);
    
      let newPage;
    
      await page.setCookie(...cookies);
      await page.goto('https://aviso.bz/work-youtube', {waitUntil: 'networkidle0'});
    //await delay(1000);
      let c = 0;
      while(true) {
    
      if(c == 100) {
        await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
        c = 0;
      }
    
    let t = await page.$('[id^="ads-link-"]');
    if(t == null) {
    console.log('wait new tasks...');
    await delay(10);
    await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
    c = 0;
    continue;
    }
    let tt = await t.evaluate((q) => getComputedStyle(q).display);
    if(tt == 'none') {
    console.log('del inactive')
    page.evaluate(q => { document.querySelector('[id^="ads-link-"]').remove(); })
    continue;
    }
    
    let tr = await page.$('tr[class^="ads_"]');
    let span = await tr.$('[onclick^="funcjs[\'start_youtube"]');
    let title = await span.evaluate(el => el.textContent.trim());
    console.log('title: \''+title+'\'');
    let sec = await tr.$('td[align="right"] span[class="serf-text"]');
    let secs = await sec.evaluate(el => el.textContent.trim());
    console.log('sec: ' + secs.split(' ')[0]);
    
    let newPagePromise = new Promise(x => browser.once('targetcreated', target => x(target.page())));
    
    //await page.waitForSelector('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
    //let x = await page.$('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
    //console.log(x.click);
    await page.waitForTimeout(2000);
    try {
    await page.click('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
    }
    catch(e) {
    console.log('error! del item');
    await page.evaluate(() => {
        document.querySelector('tr[class^="ads_"]').remove()
      });
    continue; } await page.waitForSelector('span[onclick^="funcjs[\'open_window\']"]', { timeout: 60000 }); await delay2(randomInteger(700, 2000)); await page.click('span[onclick^="funcjs[\'open_window\']"]'); newPage = await newPagePromise; await newPage.bringToFront(); const userAgent = await newPage.evaluate(() => navigator.userAgent ); console.log(userAgent) //let pages = await browser.pages(); console.log('> '+newPage.url()); await newPage.waitForSelector('tr[id="timer-tr-block"]', { timeout: 200000 }); await delay(randomInteger(2, 4)); console.log('yt click'); const frame = await newPage.waitForSelector('iframe'); let rect = await newPage.evaluate(el => { let {width, height} = el.getBoundingClientRect(); return {width, height}; }, frame); await newPage.mouse.click(rect.width / 2, rect.height / 2); //execFileSync('xdotool', ['mousemove', '960', '611']); //execFileSync('xdotool', ['click', '1']); console.log('waiting'); await newPage.waitForSelector('a[href=""]', { timeout: 200000 }); console.log('ok'); await delay2(randomInteger(900, 1500)); //console.log('> '+newPage.url()); await newPage.close(); await delay2(500); await page.bringToFront(); await page.evaluate(() => { document.querySelector('tr[class^="ads_"]').remove() }); await delay(randomInteger(1, 3)); console.log('c: '+ ++c +"\n"); } await browser.close(); })();

    автосборщик бабла для aviso

    paroljanet, 23 Мая 2022

    Комментарии (12)
  10. JavaScript / Говнокод #28182

    −10

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    const puppeteer = require('puppeteer-core');
    const fs = require('fs');
    const getCurrentLine = require('get-current-line').default;
    const { execFileSync } = require('child_process');
    
    const data = fs.readFileSync('profitcentr.com.cookies.json');
    const cookies = JSON.parse(data.toString());
    
    function randomInteger(min, max) {
      let rand = min - 0.5 + Math.random() * (max - min + 1);
      return Math.round(rand);
    }
    
    function delay(time) {
       return new Promise(function(resolve) {
           setTimeout(resolve, time*1000)
       });
    }
    
    function delay2(time) {
       return new Promise(function(resolve) {
           setTimeout(resolve, time)
       });
    }
    
    (async () => {
      const browser = await puppeteer.launch({
        headless: false,
        defaultViewport: null,
        executablePath: '/usr/bin/chromium',
    devtools: false,
        args: [
    '--start-maximized',
     ]
      });
    
      const page = await browser.newPage();
      await page.setDefaultNavigationTimeout(0);
    
      let newPage;
    
      await page.setCookie(...cookies);
      await page.goto('https://profitcentr.com', {waitUntil: 'networkidle0'});
    let link = await page.$('a[href^="./work-youtube"]');
    console.log('go to youtube')
    await link.click();
    await page.waitForTimeout(1000);
    
      let c = 0;
      while(true) {
    
      if(c == 100) {
        await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
        c = 0;
      }
    
    let t = await page.$('[id^="ads-link-"]');
    
    if(t == null) {
    console.log('wait new tasks...');
    await delay(10);
    await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
    c = 0;
    continue;
    }
    
    let tt = await t.evaluate((q) => getComputedStyle(q).display);
    if(tt == 'none') {
    console.log('del inactive')
    page.evaluate(q => { document.querySelector('[id^="ads-link-"]').remove(); })
    continue;
    }
    
    let tr = await page.$('tr[class^="ads_"]');
    let span = await tr.$('[onclick^="funcjs[\'start_youtube"]');
    let title = await span.evaluate(el => el.textContent.trim());
    console.log('title: \''+title+'\'');
    let price = await tr.$('[title^="Стоимость"]');
    let prices = await price.evaluate(el => el.textContent.trim());
    console.log('price: ' + prices);
    
    let newPagePromise = new Promise(x => browser.once('targetcreated', target => x(target.page())));
    
    //await page.waitForSelector('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
    //let x = await page.$('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
    //console.log(x.click);
    await page.waitForTimeout(1000);
    try {
    await page.click('tr[class^="ads_"] span[onclick^="funcjs[\'start_youtube"]');
    }
    catch(e) {
    console.log('error! del item'); await page.evaluate(() => { document.querySelector('tr[class^="ads_"]').remove() }); continue; } await page.waitForSelector('span[onclick^="funcjs[\'open_window"]', { timeout: 60000 }); await delay2(randomInteger(700, 2000)); await page.click('span[onclick^="funcjs[\'open_window"]'); //newPage = await newPagePromise; await page.waitForTimeout(2000); let p = await browser.pages() newPage = p[2]; await newPage.bringToFront(); console.log('> '+newPage.url()); await newPage.waitForSelector('tr[id="timer-tr-block"]', { timeout: 60000 }); await delay(3); console.log('yt click'); const frame = await newPage.waitForSelector('iframe'); let rect = await newPage.evaluate(el => { let {width, height} = el.getBoundingClientRect(); return {width, height}; }, frame); await newPage.mouse.click(rect.width / 2, rect.height / 2); console.log('waiting'); await newPage.waitForSelector('[id="capcha-tr-block"][style="display: table-row;"]', { timeout: 350000 }); let btn = await newPage.$('[class="butt-nw"]'); await btn.click(); console.log('ok'); await delay2(randomInteger(900, 1500)); //console.log('> '+newPage.url()); await newPage.close(); await delay2(500); await page.bringToFront(); await page.evaluate(() => { document.querySelector('tr[class^="ads_"]').remove() }); await delay(randomInteger(1, 3)); console.log('c: '+ ++c +"\n"); } await browser.close(); })();

    тупо грабер для profitcentr! в день рубль нихуя не делая поднимаю на нем
    ее палится

    paroljanet, 23 Мая 2022

    Комментарии (1)