View difference between Paste ID: Q8tSx7AH and 89hVFF5W
SHOW: | | - or go back to the newest paste.
1
(function() {
2
    // Array of random image URLs from Catbox
3
    const imageUrls = [
4
        'https://files.catbox.moe/6duawu.png',
5
        'https://files.catbox.moe/grz6rr.png',
6
        'https://files.catbox.moe/k1h5xa.png',
7
        'https://files.catbox.moe/n1x0cw.png',
8
        'https://files.catbox.moe/jhzncd.png',
9
        'https://files.catbox.moe/aziy5r.png',
10
        'https://files.catbox.moe/w14ev1.png',
11
        'https://files.catbox.moe/qjfppr.png',
12
        'https://files.catbox.moe/y6uk9a.png',
13
        'https://files.catbox.moe/u47zuz.png',
14
        'https://files.catbox.moe/ilgg4s.png',
15
        'https://files.catbox.moe/5gvcbf.png',
16
        'https://files.catbox.moe/9h7n2o.png',
17
        'https://files.catbox.moe/t94b16.png',
18
        'https://files.catbox.moe/5nhfnd.png',
19
        'https://files.catbox.moe/q611x8.png',
20
        'https://files.catbox.moe/llfe6u.png',
21
        'https://files.catbox.moe/xofz8h.png',
22
        'https://files.catbox.moe/oo1dyf.png',
23
        'https://files.catbox.moe/wagnv8.png',
24
        'https://files.catbox.moe/f2t5wx.png',
25
        'https://files.catbox.moe/wn3lnb.png',
26
        'https://files.catbox.moe/0hovzu.png',
27
        'https://files.catbox.moe/o51j3x.png',
28
        'https://files.catbox.moe/f3m0hn.png',
29
        'https://files.catbox.moe/l5g9hz.png',
30
        'https://files.catbox.moe/gtzrly.png',
31
        'https://files.catbox.moe/2uhqmh.png',
32
        'https://files.catbox.moe/c1thg9.png',
33
        'https://files.catbox.moe/vpb8zb.png',
34
        'https://files.catbox.moe/ap62c3.png',
35
        'https://files.catbox.moe/oew6wr.png',
36
        'https://files.catbox.moe/ko07dx.png',
37
        'https://files.catbox.moe/p2utwj.png',
38
        'https://files.catbox.moe/vdyn8f.png',
39
        'https://files.catbox.moe/pg27k4.png',
40
        'https://files.catbox.moe/kl3zl6.png',
41
        'https://files.catbox.moe/dlgoxk.png',
42
        'https://files.catbox.moe/b6o7jw.gif',
43
        'https://files.catbox.moe/nphjxw.png',
44
        'https://files.catbox.moe/tnhi9y.png',
45
        'https://files.catbox.moe/a2z5d1.png',
46
        'https://files.catbox.moe/h5n1u4.png',
47
        'https://files.catbox.moe/nb4zc8.png',
48
        'https://files.catbox.moe/gdbcsa.png',
49
        'https://files.catbox.moe/zbi7uc.png',
50
        'https://files.catbox.moe/gs766f.png'
51
    ];
52
53
    // Helper function to get a random item from an array
54
    function getRandomItem(arr) {
55
        return arr[Math.floor(Math.random() * arr.length)];
56
    }
57
58
    // Function to simulate a file drop on the file input
59
    async function simulateFileUpload() {
60
        const randomImageUrl = getRandomItem(imageUrls);
61
        const imageName = randomImageUrl.split('/').pop(); // Extract the file name from the URL
62
63
        // Fetch the image data
64
        try {
65
            const response = await fetch(randomImageUrl);
66
            if (!response.ok) {
67
                console.error('Failed to fetch image:', randomImageUrl);
68
                return;
69
            }
70
71
            const blob = await response.blob();
72
            const file = new File([blob], imageName, { type: blob.type });
73
74
            // Create a DataTransfer object and add the file to it
75
            const dataTransfer = new DataTransfer();
76
            dataTransfer.items.add(file);
77
78
            // Find the file input and set the file
79-
            const fileInput = document.querySelector('input[name="upfile"]');
79+
            const fileInput = document.querySelector('#upload_file');
80
            if (fileInput) {
81
                fileInput.files = dataTransfer.files;
82
            } else {
83
                console.error('File input not found.');
84
            }
85
        } catch (error) {
86
            console.error('Error fetching image:', error);
87
        }
88
    }
89
90
    // Function to populate the text field
91
    function populateTextField() {
92
        // Find the textarea and set random text
93-
        const textArea = document.querySelector('textarea[name="com"]');
93+
        const textArea = document.querySelector('#body');
94
        if (textArea) {
95
            textArea.value = "Wow! Very nice art!";
96
        } else {
97
            console.error('Textarea not found.');
98
        }
99
    }
100
101
    // Function to submit the form
102
    function submitForm() {
103-
        const submitButton = document.querySelector('input[type="submit"]');
103+
        const submitButton = document.querySelector('input[name="post"]');
104
        if (submitButton) {
105
            submitButton.click();
106
        } else {
107
            console.error('Submit button not found.');
108
        }
109
    }
110
111
    // Main function to run the sequence
112
    function postThread() {
113
        // 1. Click the "Start a New Thread" button
114-
        const newThreadButton = document.querySelector('#togglePostFormLink a');
114+
        const newThreadButton = document.querySelector('input[name="post"]');
115
        if (newThreadButton) {
116
            newThreadButton.click();
117
        } else {
118
            console.error('New Thread button not found.');
119
            return; // Stop the process if the button isn't found
120
        }
121
122
        // 2. Simulate the file upload
123
        setTimeout(simulateFileUpload, 7000); // Wait 1 second before uploading the file
124
125
        // 3. Populate the text field
126
        setTimeout(populateTextField, 2000); // Wait 2 seconds before populating the text
127
128
        // 4. Submit the form after everything is set
129
        setTimeout(submitForm, 3000); // Submit 3 seconds after the initial button click
130
    }
131
132
    // Run the process
133
    postThread();
134
})();