これら 2 つのスクリプトを GM 用に組み合わせる必要があります。1 つはリストから新しいページを開き、もう 1 つは「フォロー」ボタンをクリックします。
スクリプト 1:ページのリストを自動的に順番に開くには?
スクリプト 2: Greasemonkey でこのボタンをクリックするにはどうすればよいですか?
私はそれらを自分で結合しようとしましたが、リストに順番に配置されていても、ページを完全にリロードする作業スクリプトを作成できませんでした (他の質問を読めば、私の意味が理解できます)。
これは私が試したものですが、ページを適切にリロードしてタスクを続行しないため、期待どおりに機能しません。
// ==UserScript==
// @name Follow People on INK361
// @description Follow People from our FB Page's list INK361
// @include http://ink361.com*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/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 major design
change introduced in GM 1.0.
It restores the sandbox.
*/
var urlsToLoad = [
'http://ink361.com/#/users/30742610/photos',
'http://ink361.com/#/users/193869245/photos',
'http://ink361.com/#/users/215062853/photos',
'http://ink361.com/#/users/218295575/photos'
];
/*--- Since many of these sites load large pictures, Chrome's and
Firefox's injection may fire a good deal before the image(s)
finish loading.
So, insure script fires after load:
*/
//--- Catch new pages loaded by WELL BEHAVED ajax.
window.addEventListener ("hashchange", FireTimerA, false);
function FiretimerA () {
waitForKeyElements ("a.simplebutton:contains('follow')", FireTimer());
}
function FireTimer (jNode) {
if ( ! /^\s*follow\s*$/i.test () ) {
return false;
}
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
jNode[0].dispatchEvent (clickEvent);
GotoNextURL();
}
function GotoNextURL () {
var numUrls = urlsToLoad.length;
var urlIdx = urlsToLoad.indexOf (location.href);
urlIdx++;
if (urlIdx >= numUrls)
urlIdx = 0;
location.href = urlsToLoad[urlIdx];
}