Copy ASF Code Button

Adds a button to copy ASF code to clipboard

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Copy ASF Code Button
// @namespace    http://tampermonkey.net/
// @version      1.01
// @description  Adds a button to copy ASF code to clipboard
// @author       祈之羽
// @match        https://keylol.com/*
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var hasSteamAppPaths = Array.from(document.querySelectorAll('a[href]')).some(link => link.href.includes('store.steampowered.com/app/'));
    if (hasSteamAppPaths) {
        var copyButton = document.createElement('button');
        copyButton.innerHTML = 'Copy ASF Code';
        copyButton.style.position = 'fixed';
        copyButton.style.top = '20px';
        copyButton.style.left = '20px';
        copyButton.style.zIndex = '9999';
        copyButton.addEventListener('click', function() {
            var links = document.querySelectorAll('a[href]');
            var numbers = new Set();
            links.forEach(function(link) {
                var match = link.href.match(/store\.steampowered\.com\/app\/(\d+)/);
                if (match) {
                    numbers.add(match[1]);
                }
            });
            var asfCode = '!addlicense asf ' + Array.from(numbers).map(number => 'a/' + number).join(',');
            GM_setClipboard(asfCode);
            alert('ASF code copied to clipboard!');
        });
        document.body.appendChild(copyButton);
    }
})();