A
A
Andrew2015-01-27 22:59:34
JavaScript
Andrew, 2015-01-27 22:59:34

How to execute scripts on a page from userscripts?

There is a page on which there is a certain amount of select , when a certain item is selected, the data is loaded onto the page, userscripts selects the select element, but then the data is not loaded, how is it possible to continue the script execution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hotamateurxxx, 2015-01-28
@hotamateurxxx

/** Добавление скрипта текстом
    *
    * @param String text Текст скрипта
    * @param String parent Селектор родителя
    * @return Element Добавленный элемент
    */
    appendScriptText: function(text, parent) {
        var node = document.createElement('script');
        node.setAttribute('type', 'text/javascript');
        node.text = text;
        $(parent).prepend(node); // Инструкция с использованием jQuery, думаю можно безболезненно заменить на parent.appendChild(node)
        return node;
    },

Works from IE6+ to Mozilla latest versions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question