forked from killtw/AJAX-Pixiv-Bookmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax_pixiv_bookmark.user.js
57 lines (52 loc) · 2.05 KB
/
ajax_pixiv_bookmark.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ==UserScript==
// @id ajax_pixiv_bookmark
// @name AJAX Pixiv Bookmark
// @version 1.0.1
// @namespace http://blog.k2ds.net/
// @author killtw
// @description Using AJAX to add a bookmark in Pixiv
// @match http://www.pixiv.net/member_illust.php?*
// @include http://www.pixiv.net/member_illust.php?*
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main() {
$("div.bookmark-container a._button").live('click', function(e) {
e.preventDefault();
var tt = $('input[name="tt"]').val();
var illust_id = $('div#rpc_i_id').attr('title');
$.ajax({
url: 'bookmark_add.php',
data: {
mode: 'add',
tt: tt,
id: illust_id,
type: 'illust',
form_sid: '',
restrict: '0'
},
dataType: 'html',
type: 'POST',
beforeSend: function() {
$("div.bookmark-container a._button").text('追加中…');
},
success: function() {
$("div.bookmark-container a._button").text('加入成功');
// $('div.bookmark').load('member_illust.php?mode=medium&illust_id='+illust_id+' div.bookmark');
$('div.bookmark-container').fadeOut('fast').html('[ <a href="bookmark_detail.php?illust_id=' + illust_id + '">ブックマーク済み</a> | <a href="bookmark_add.php?type=illust&illust_id=' + illust_id + '">編輯</a> ]').fadeIn('fast');
}
});
return false;
});
}
addJQuery(main);
GM_addStyle(".AutoPager_Related, .ads_area { display:none !important; }");