我想從https://play.google.com/store/account*
中獲取一個值,它使用戶頁面通過它的輸出。例如:
/store/account?start=0&num=40
,然後/store/account?start=40&num=40
等Greasemonkey可以從分頁的URL序列中獲取值嗎?
現在,當我訪問https://play.google.com/apps
,我想向Greasemonkey的TOT-了從/store/account
頁面的值,然後顯示該網頁上的最終值。
下面列出的代碼可以從/store/account
頁面獲得我想要的值。但是,我想將代碼插入用於第二個URL的腳本中,因此我可以在同一頁面上添加它。
// ==UserScript==
// @name Google Play
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
var startParam = location.search.match (/\bstart=(\d+)/i);
if (startParam) {
var totalPrice = 0;
var startNum = parseInt (startParam[1], 10);
if (startNum === 0) {
GM_setValue ("TotalPrice", "0");
}
else {
totalPrice = parseFloat (GM_getValue ("TotalPrice", 0));
}
$("#tab-body-account .rap-link").each(function() {
var price = $(this).attr ("data-docprice").replace (/[^\d\.]/g, "");
if (price) {
price = parseFloat (price);
if (typeof price === "number") {
totalPrice += price;
}
}
});
//console.log ("totalPrice: ", totalPrice.toFixed(2));
$('.tabbed-panel-tab').before (
'<div id="SumTotal">*Combined Value: $'+ totalPrice.toFixed(2) +'</div>'
);
GM_setValue ("TotalPrice", "" + totalPrice);
if ($(".snippet.snippet-tiny").length) {
startNum += 40;
var nextPage = location.href.replace (
/\bstart=\d+/i, "start=" + startNum
);
location.assign (nextPage);
}
}
哇,這工作完美無瑕。再次感謝Brock! – user1774640
不客氣。樂意效勞。 –