Force Tampermonkey to run/execute script late

拜拜、爱过 提交于 2019-12-05 16:49:36
Brock Adams

The content you want is being loaded by AJAX, so you need to use AJAX-compensation techniques in your script.

The easiest way to do that is to use waitForKeyElements(). Something like:

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/

waitForKeyElements (
    "jQUERY SELECTOR TO THE NODE(S) YOU WANT",
    changeFontColor
);

function changeFontColor (jNode) {
    jNode.css ("color", "red");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!