", {
id: "formClearButton",
text: "[クリア]",
css: {
cursor: "pointer",
margin: "0 5px"
},
click: function() {
clearForm();
}
});
var $comeTd = $(".ftdc b:contains('コメント')");
$comeTd.after($formClearButton);
}
function clearForm() {
$("#ftxa").val("");
}
}
function addCss() {
GM_addStyle(
"@keyframes spin {" +
" 0% { transform: rotate(0deg); }" +
" 100% { transform: rotate(359deg); }" +
"}"
);
}
// タブのアクティブ状態を取得
function setWindowFocusEvent() {
$(window).bind("focus", function() {
// タブアクティブ時
isWindowActive = true;
}).bind("blur", function() {
// タブ非アクティブ時
isWindowActive = false;
});
}
// 新着レスをポップアップでデスクトップ通知する
function showNotification(body) {
Notification.requestPermission();
var icon = $("#akahuku_thumbnail").attr("src");
var instance = new Notification(
document.title, {
body: body,
icon: icon,
}
);
}
/**
* 次スレ候補検索ボタン表示
*/
function showFindNextThread() {
$("body").append(
$("
", {
id: "GM_FAR_next_thread_area",
class: "GM_FAR"
}).append(
$("
").append(
$("
", {
id: "GM_FAR_find_next_thread",
class: "GM_FAR_Button",
text: "[次スレ候補検索]",
css: {
cursor: "pointer",
"font-size": "9pt"
},
click: function() {
findNextThread();
}
}),
$("", {
id: "GM_FAR_next_thread_search_result",
css: {
"display": "none",
"font-size": "9pt"
}
}).append(
$("", {
text: "検索結果:",
}),
$("", {
id: "GM_FAR_next_thread_search_result_count",
text: "0"
})
)
),
$("", {
"id": "GM_FAR_next_thread_found"
}).append(
$("", {
id: "GM_FAR_next_thread_search_status",
text: "次スレ候補検索中...",
css: {
"display": "none"
}
})
)
)
)
}
/**
* 次スレ候補検索
*/
function findNextThread() {
var foundList = $("#GM_FAR_next_thread_found");
foundList.empty()
var statusMessage = $("#GM_FAR_next_thread_search_status")
statusMessage.show();
var dir = location.href.substr(0, location.href.lastIndexOf('/') - 3);
var threadTitle = $("#akahuku_thread_text").text().substr(0, 4);
var catalogURL = dir + "futaba.php?mode=cat&sort=1"
var resultCount = 0;
GM_xmlhttpRequest({
method: "GET",
url: catalogURL,
onload: function(res) {
statusMessage.hide();
var catalog = $($.parseHTML(res.response));
var cattable = catalog.filter("#cattable");
var td = cattable.find("td small");
td.each(function() {
var tdText = $(this).text()
if( tdText.substr(0, 4) == threadTitle) {
resultCount++;
var foundThread = $(this).parent().find("a");
var foundThreadResCount = $(this).parent().find("font").text();
var href = foundThread.attr("href");
foundThread.attr("href", dir + href);
foundList.append(
$("- ").append(
$(this),
$("", {
text: foundThreadResCount + "レス",
css: {
"margin-left": "2em"
}
}),
foundThread
)
);
}
});
$("#GM_FAR_next_thread_search_result_count").text(resultCount);
$("#GM_FAR_next_thread_search_result").show();
}
});
}
})(jQuery);