Can running this javascript be harmful to my computer?

Hey a complete novice in code here. One day I noticed a strange looking file that was in my downloads folder and being the idiot I am I decided to double click it without a single thought. When I did, I got a “windows script host” dialog box saying some sort of error. Now upon closer inspection I realized it was a backup of a script that I downloaded for tampermonkey some while back. I know the script works properly on my google chrome, but I’m just afraid that by double clicking on the script in file explorer I may have screwed up something on my computer…. So can anyone knowledgeable give me some insight in the simplest terms into what might have happened when I double clicked on the file? Could I have damaged my PC?

I tried opening it in notepad to see what was up, but being a complete novice in coding, I just can’t tell what happened.

Here is the code I copied from notepad

// ==UserScript==
// @name            YouTube Playlist AutoPlay
// @namespace       https://github.com/crazyrabbit0
// @version         2.1.4
// @description     AutoPlay next Playlist item in YouTube
// @author          CrazyRabbit
// @match           http://*.youtube.com/*
// @match           https://*.youtube.com/*
// @icon            https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant           none
// @license         GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @copyright       2023+, CrazyRabbit (https://github.com/crazyrabbit0)
// @homepageURL     https://github.com/crazyrabbit0/UserScripts
// @supportURL      https://github.com/crazyrabbit0/UserScripts/issues/new?assignees=crazyrabbit0&labels=help+wanted&template=&title=YouTube%20Playlist%20AutoPlay%20-%20Issue
// @run-at          document-start
// @noframes
// @downloadURL https://update.greasyfork.org/scripts/480708/YouTube%20Playlist%20AutoPlay.user.js
// @updateURL https://update.greasyfork.org/scripts/480708/YouTube%20Playlist%20AutoPlay.meta.js
// ==/UserScript==

(function() {
    'use strict'

    let elements = {
        player: null,
        next_video: null,
        progress: null,
        loop: null
    }

    let loaded = {
        player: false,
        progress: false
    }

    let loop = {
        code: null,
        value: null,
        map: {
            //'M21': '',
            'M20': 'playlist',
            'M13': 'video'
        }
    }

    function play_next_video(player = elements.player) {
        elements.next_video = document.querySelector('ytd-playlist-panel-video-renderer[selected] + ytd-playlist-panel-video-renderer > a')
        if(player.classList.contains('ended-mode')) {
            let has_video_loop = elements.loop.querySelector('path')?.getAttribute('d').substring(0, 3) === 'M13'
            //let ads = document.querySelector('.video-ads')
            if(!has_video_loop) {
                elements.next_video?.click()
            }
            //console.log('video-ended')
        }
        else if(player.querySelector('.html5-ypc-title')?.innerText) {
            elements.next_video?.click()
            //console.log('video-cannot-start')
        }
    }

    function reset_loop(progress = elements.progress) {
        if(!progress.hasAttribute('hidden')) {
            loop.code = elements.loop.querySelector('path')?.getAttribute('d').substring(0, 3)
            loop.value = loop.code.replace(/Md+/, function(match) { return loop.map[match] || '' })
            //console.log('progress-started')
        }
        else {
            switch (loop.value) {
                case 'video':
                    elements.loop.click()
                    /* falls through */
                case 'playlist':
                    setTimeout(function() { elements.loop.click() }, 1)
            }
            //console.log('progress-finished')
        }
    }

    let loaded_check = setInterval(function() {
        if(!loaded.player && elements.player && elements.next_video) {
            loaded.player = true
            play_next_video()
            new MutationObserver(function(mutations) {
                for(const mutation of mutations) {
                    play_next_video(mutation.target)
                }
            }).observe(elements.player, {
                attributeFilter: [ "class" ]
            })
        }
        else {
            elements.player = document.querySelector('div#movie_player')
            elements.next_video = document.querySelector('ytd-playlist-panel-video-renderer[selected] + ytd-playlist-panel-video-renderer > a')
        }

        if(!loaded.progress && elements.progress && elements.loop) {
            loaded.progress = true
            reset_loop()
            new MutationObserver(function(mutations) {
                for(const mutation of mutations) {
                    reset_loop(mutation.target)
                }
            }).observe(elements.progress, {
                attributeFilter: [ "hidden" ]
            })
        }
        else {
            elements.progress = document.querySelector('yt-page-navigation-progress')
            elements.loop = document.querySelector('ytd-playlist-loop-button-renderer button')
        }

        if(Object.values(loaded).every(Boolean)) {
            clearInterval(loaded_check)
            //console.log('all-elements-loaded')
        }
    }, 500)
})()

New contributor

SSSDerozen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật