chronous

Jukebox Tedeteksi Lagu Jawir !!!

Feb 5th, 2025 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 3.44 KB | Source Code | 0 0
  1. // Load jQuery
  2. var script = document.createElement('script');
  3. script.src = "https://code.jquery.com/jquery-3.6.0.min.js";
  4. document.head.appendChild(script);
  5.  
  6. script.onload = function() {
  7.     console.log("jQuery berhasil dimuat!");
  8.  
  9.     setInterval(function () {
  10.         let adderCount = {};
  11.  
  12.         $('[data-adder-id]').each(function () {
  13.             let adderId = $(this).attr('data-adder-id');
  14.             adderCount[adderId] = (adderCount[adderId] || 0) + 1;
  15.             console.log(`ID: ${adderId}, Jumlah: ${adderCount[adderId]}`);
  16.         });
  17.  
  18.         async function detectLanguage(text, callback) {
  19.             const API_KEY = '<<YOUR_API_KEY_FROM_GOOGLE_STUDIO_AI>>';
  20.            
  21.             // Menggunakan fetch untuk memanggil API Gemini secara langsung
  22.             const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${API_KEY}`, {
  23.                 method: 'POST',
  24.                 headers: {
  25.                     'Content-Type': 'application/json',
  26.                 },
  27.                 body: JSON.stringify({
  28.                     contents: [{
  29.                         parts: [{
  30.                             text: `Apakah teks berikut ini merupakan lirik lagu berbahasa Jawa? Jawab hanya 'ya' atau 'tidak': ${text}`
  31.                         }]
  32.                     }]
  33.                 })
  34.             });
  35.  
  36.             try {
  37.                 const data = await response.json();
  38.                 if (data.candidates && data.candidates[0] && data.candidates[0].content) {
  39.                     const answer = data.candidates[0].content.parts[0].text.toLowerCase();
  40.                     const isJavanese = answer.includes('ya');
  41.                     callback(isJavanese);
  42.                 } else {
  43.                     console.error('Unexpected API response format:', data);
  44.                     callback(false);
  45.                 }
  46.             } catch (err) {
  47.                 console.error('Error detecting language:', err);
  48.                 callback(false);
  49.             }
  50.         }
  51.  
  52.         console.table(adderCount);
  53.         $.each(adderCount, function (id, count) {
  54.             console.log("Jumlah: " + count);
  55.             if (count > 5) {
  56.                 let excess = count - 5;
  57.                 $(`[data-adder-id="${id}"]`).get().reverse().slice(0, excess).forEach(function (element) {
  58.                     console.log("Element: " + element);
  59.  
  60.                     let $element = $(element);
  61.                     let username = $element.find('.item__username').text().replace('Added By ', '').trim();
  62.                     let lagu = $element.find('.item__title').text().trim();
  63.  
  64.                     detectLanguage(lagu, function (isJavanese) {
  65.                         console.log(`Judul: "${lagu}", Apakah Jawa: ${isJavanese}`);
  66.  
  67.                         if (!isJavanese) {
  68.                             $element.find('[data-t="Delete"]:not(.processed)').each(function () {
  69.                                 $(this).addClass('processed').click();
  70.                                 console.log(`Klik 'Delete' ATAS NAMA: ${username} untuk data-adder-id: ${id}`);
  71.                                 $('.js-message-input').val(`${username} melakukan pelanggaran , "${lagu}" DIHAPUS karena lagu jawir !!!`);
  72.                                 $('.js-send').click();
  73.                             });
  74.                         }
  75.                     });
  76.                 });
  77.             }
  78.         });
  79.     }, 8000);
  80. };
Tags: js Jukebox
Advertisement
Add Comment
Please, Sign In to add comment