ahoy injector

yandex searcher for kinopoisk card

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         ahoy injector
// @version       0.0.2
// @author        dEN5
// @include        https://yandex.ru/search/?text=*
// @require       http://cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js
// @grant         none
// @description yandex searcher for kinopoisk card
// @license MIT
// @namespace https://greasyfork.org/users/739921
// ==/UserScript==

function createElementFromHTML(htmlString) {
  var div = document.createElement('div');
  div.innerHTML = htmlString.trim();
  return div.firstChild;
}



window.onload = function() {
    const panel = document.querySelector('div[class^="entity-search entity-search_entref_"]')
    var observer = new MutationObserver(function(mutations) {
        const panelButtons = panel.querySelector('div[class="entity-search__sites"] > div[class^="Root"] > div[class^="EntitySites"]')
        const firstElementChild = panelButtons.firstElementChild
        const id_movie = firstElementChild.getAttribute("href").toString().trim().match(/(?<id>\/\d*)/gi)[3].replace("/","");
        let btnView = createElementFromHTML(`<a  target="_blank" href="https://4h0y.gitlab.io/#${id_movie}" class="Button2 Button2_size_m Button2_view_clear Button2_type_link EntitySites-Button"><div class="EntitySites-Icon "></div><span class="Button2-Text">Начать просмотр</span></a>`)
        panelButtons.appendChild(btnView)
        observer.disconnect();

    });
    observer.observe(panel, {attributes: false, childList: true, characterData: false, subtree:true});



};