Sukebei MissAV Button

Adds a blue MissAV button with favicon, a single 'or' separator, and a SexTB button.

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Sukebei MissAV Button
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Adds a blue MissAV button with favicon, a single 'or' separator, and a SexTB button.
// @author       phnthnhnm
// @match        https://sukebei.nyaa.si/view/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 1. Find the torrent title element
    const titleElement = document.querySelector('h3.panel-title');
    if (!titleElement) return;

    const titleText = titleElement.textContent.trim();

    // 2. Extract the code using Regex
    // Pattern: alphanumeric chars, a dash, then numbers (e.g., abcd123-01234)
    const regex = /[a-zA-Z0-9]+-\d+/;
    const match = titleText.match(regex);

    // If no code is found, stop execution
    if (!match) {
        console.log('MissAV Button: No code found in title.');
        return;
    }

    const code = match[0];

    // 3. Find the Magnet button
    const magnetBtn = document.querySelector('a[href^="magnet:"]');
    if (!magnetBtn) return;

    // 4. Create the "or" text separators
    const orText1 = document.createTextNode(' or ');
    const orText2 = document.createTextNode(' or ');

    // 5. Create the "MissAV" button
    const missBtn = document.createElement('a');
    missBtn.href = `https://missav.ws/en/${code}`;
    missBtn.target = '_blank';
    missBtn.textContent = 'MissAV';

    // 6. Add the MissAV Favicon
    const faviconMiss = document.createElement('img');
    faviconMiss.src = 'https://www.google.com/s2/favicons?domain=missav.ws&sz=16';
    faviconMiss.style.height = '14px';
    faviconMiss.style.width = '14px';
    faviconMiss.style.marginRight = '5px';
    faviconMiss.style.verticalAlign = 'text-bottom';
    faviconMiss.style.border = 'none';
    missBtn.prepend(faviconMiss);

    // 7. Create the "SexTB" button
    const sexTbBtn = document.createElement('a');
    sexTbBtn.href = `https://sextb.net/${code}`;
    sexTbBtn.target = '_blank';
    sexTbBtn.textContent = 'SexTB';

    // 8. Add the SexTB Favicon
    const faviconSextb = document.createElement('img');
    faviconSextb.src = 'https://www.google.com/s2/favicons?domain=sextb.net&sz=16';
    faviconSextb.style.height = '14px';
    faviconSextb.style.width = '14px';
    faviconSextb.style.marginRight = '5px';
    faviconSextb.style.verticalAlign = 'text-bottom';
    faviconSextb.style.border = 'none';
    sexTbBtn.prepend(faviconSextb);

    // 9. Insert elements into the DOM
    
    // Insert first separator and MissAV Button
    magnetBtn.parentNode.insertBefore(orText1, magnetBtn.nextSibling);
    magnetBtn.parentNode.insertBefore(missBtn, orText1.nextSibling);

    // Insert second separator and SexTB Button
    magnetBtn.parentNode.insertBefore(orText2, missBtn.nextSibling);
    magnetBtn.parentNode.insertBefore(sexTbBtn, orText2.nextSibling);

})();