1. 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)
  2. 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)
  3. JavaScript / Говнокод #28127

    +3

    1. 1
    2. 2
    // remove "s" ending: minute/hour/day/week/month/year don't have "s" in the body
    const period = periodName.split("s").join(""); // days -> day

    И тут решили добавить секунды...

    dhilt, 19 Апреля 2022

    Комментарии (13)
  4. JavaScript / Говнокод #28095

    0

    1. 1
    console.log('Hello from GovnoKod!');

    aivanov-ru, 28 Марта 2022

    Комментарии (1)
  5. JavaScript / Говнокод #28089

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function main()
    {
        for (const i of [1, 2, 3])
            print("Hello World!", i);
    }

    ну что вершилось чудо.. теперь на https://godbolt.org/ можно попробывать альфа версию компилятора
    пока показывает только - LLVM IR и вывод выполнения
    https://i.postimg.cc/Kj3Bd78d/god-bolt-tsc-native.jpg

    [god-bolt-tsc-native.jpg](https://postimg.cc/QKsF7T5b)

    ASD_77, 23 Марта 2022

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

    −2

    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
    96. 96
    97. 97
    98. 98
    99. 99
    from lib2to3.pgen2 import token
    import logging
    import re
    
    import requests
    import pandas as pd
    
    from bs4 import BeautifulSoup
    
    from aiogram import Bot, Dispatcher, executor, types
    from aiogram.dispatcher.filters import Text
    
    bot = Bot(token="5243563589:AAHZL9JyJ0Q36dBpuXcjgzDuM-0n9OEWhpk")
    dp = Dispatcher(bot)
    logging.basicConfig(level=logging.INFO)
    
    sso = "http://pinskgptklp.brest.by/sso.html"
    pto = "http://pinskgptklp.brest.by/pto2.html"
    logg = ""
    
    response = requests.get(sso)
    soup = BeautifulSoup(response.text, "lxml")
    quotes = soup.find_all("tbody")
    t = str(quotes)
    arr = t.split('</tbody>, ')
    stroka = arr[1]
    stroki = stroka.split('<tr')
    
    i = 1
    j = 0
    
    tablica = [0] 8
    ttt = [[]] 8
    
    tab1 = [0] len(stroki)
    while i < len(tab1):
    j = 0
    tab1 = re.sub(r'\n+', '\n', stroki)
    tab1 = re.sub(r'\<[^>]\>', '', "<" + stroki).split('\n')
    while j < len(tab1):
    if tab1[j] != "" and tab1[j] != "]":
    logg += '|' + tab1[j]
    
    j = j + 1
    
    logg += '~'
    i = i + 1
    
    q = []
    rem = logg.split('~')
    o = 0
    while o < len(rem):
    q.append(rem.split('|'))
    o = o + 1
    
    o = 0
    while o < len(rem):
    o = o + 1
    
    print(q)
    
    sso_sh = q[4][1] + q[4][2] + q[4][3] + q[4][4] + '\n' + q[0][2] + " - " + q[4][5] + '\n' + q[0][3] + " - " + q[4][8]
    sso_p = q[5][1] + q[5][2] + q[5][3] + q[5][4] + '\n' + q[0][2] + " - " + q[5][5] + '\n' + q[0][3] + " - " + q[5][8]
    
    @dp.message_handler(commands="start")
    async def cmd1(message: types.Message):
    keyboard = types.InlineKeyboardMarkup()
    keyboard.add(types.InlineKeyboardButton(text="ПТО", callback_data="n1"))
    keyboard.add(types.InlineKeyboardButton(text="CCO", callback_data="n2"))
    await message.answer("Действия:", reply_markup=keyboard)
    
    #@dp.message_handler(Text(equals="Показать что-то"))
    #async def cmd2(message: types.Message):
    #await message.reply(stroki[1])
    
    @dp.callback_query_handler(text="see")
    async def see(call: types.CallbackQuery):
    await call.message.answer("123123123")
    await call.answer()
    
    @dp.callback_query_handler(text="n1")
    async def next(call: types.CallbackQuery):
    keyboard = types.InlineKeyboardMarkup()
    keyboard.add(types.InlineKeyboardButton(text=q[4][3], callback_data="pto1"))
    keyboard.add(types.InlineKeyboardButton(text=q[5][3], callback_data="pto2"))
    await call.message.answer("Что именно?", reply_markup=keyboard)
    await call.answer()
    
    @dp.callback_query_handler(text="n2")
    async def next(call: types.CallbackQuery):
    keyboard = types.InlineKeyboardMarkup()
    keyboard.add(types.InlineKeyboardButton(text=q[4][3], callback_data="sso1"))
    keyboard.add(types.InlineKeyboardButton(text=q[5][3], callback_data="sso2"))
    await call.message.answer("Что именно?", reply_markup=keyboard)
    await call.answer()
    
    @dp.callback_query_handler(text="sso1")
    async def next(call: types.CallbackQuery):
    await call.message.answer(sso_sh)

    Саб, нужна помощь с ботом, нужно сделать 2 часть с кнопкой ПТО, а то не получается спарсить

    dddccc, 24 Февраля 2022

    Комментарии (4)
  7. JavaScript / Говнокод #28028

    −3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function test(p) {
      return p +' World';
    }
    var str = 'Hello ';
    console.log(str + test());
    
    // Hello undefined World

    ltmix-web, 17 Февраля 2022

    Комментарии (13)
  8. JavaScript / Говнокод #28026

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function toHex(this: TypeOf<1>) {
    	return "hex";
    }
    
    function main() {
        print((5).toHex());
        print("done.");
    }

    решил добавить прикольного кода из C# в TypeScript Compiler ... красиво получилось? (тем кто еще не знает где искать компилятор https://github.com/ASDAlexander77/TypeScriptCompiler)

    ASD_77, 17 Февраля 2022

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

    −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
    function getPointFactory() {
        class P {
            x = 0;
            y = 0;
        }
    
        return new P();
    }
    
    function main() {
        const PointZero = getPointFactory();
        print("done.");
    }

    все шах и мат вам... с/c++

    ASD_77, 16 Февраля 2022

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function extend<T, U>(first: T, second: U): T & U {
      let result = <T & U>{};
      return result;
    }
    
    function main()
    {
    	const x = extend({ a: "hello" }, { b: 42 });
    	const s = x.a;
    	const n = x.b;
    }

    эта неделя выдалась продуктивной на говнокоды. Ну ну ну... даже и не знаю что сказать по поводу С/C++

    ASD_77, 16 Февраля 2022

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