pixiv ajax bookmark and follow

ブックマークとお気に入り登録をページ遷移なく非同期的に行います。

  1. // ==UserScript==
  2. // @name pixiv ajax bookmark and follow
  3. // @namespace
  4. // @version 0.7
  5. // @description ブックマークとお気に入り登録をページ遷移なく非同期的に行います。
  6. // @include http://www.pixiv.net/member_illust.php*
  7. // @include http://www.pixiv.net/member.php?*
  8. // @copyright 2014+, qa2
  9. // @author qa2
  10. // ==/UserScript==
  11.  
  12. //初期設定
  13. /*
  14. 参考
  15. char code list: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
  16.  
  17. */
  18.  
  19. // bkm_restrict ブックマークする作品を非公開にするかどうか 0:公開 1:非公開
  20. var bkm_restrict = 0;
  21.  
  22. // follow_restrict フォローしたユーザーを非公開にするかどうか 0:公開 1:非公開
  23. var follow_restrict = 0;
  24.  
  25. $('a[name=link]').css({'font-size':'60px'});
  26. $('a[alt=link]').css({'font-size':'60px'});
  27. $('input[name=input]').css({'font-size':'60px'});
  28.  
  29.  
  30. //eキーを押すとブクマする
  31. $(window).keydown(function(e) {
  32. if (!$("input[name=word]").is(":focus") && e.which == 69) {
  33. $(".add-bookmark").text("ブクマ編集");
  34. bkm();
  35. }
  36. });
  37.  
  38.  
  39.  
  40. //zキーを押したらユーザーをお気に入り登録する
  41. $(window).keydown(function(e) {
  42. if (!$("input[name=word]").is(":focus") && e.which == 90) {
  43. $("#favorite-button").attr("data-text-follow", "フォロー中です");
  44. $("#favorite-button > .text").text("フォロー中です");
  45. follow();
  46. }
  47. });
  48.  
  49.  
  50. // ajaxでブックマークする関数
  51. function bkm() {
  52. var illustid = $("input[name=illust_id").val();
  53. var url = "http://www.pixiv.net/bookmark_add.php?id=" + illustid
  54. var tt = $("input[name=tt]").val();
  55. var type = $("input[name=type]:eq(1)").val();
  56. //作品に登録されているすべてのタグをブックマークタグとして追加
  57. var tags = "";
  58. $(".tag > .text").each(function() {
  59. tags += $(this).text() + " "
  60. });
  61.  
  62. $.ajax({
  63. url: url,
  64. type: 'POST',
  65. dataType: 'json',
  66. data: {
  67. mode: "add",
  68. tt: tt,
  69. id: illustid,
  70. type: type,
  71. from_id: "",
  72. comment: "",
  73. tag: tags,
  74. restrict: bkm_restrict,
  75. success: function() {
  76. $(".add-bookmark _button")
  77. .removeClass(".add-bookmark _button")
  78. .addClass(".edit-bookmark button-on")
  79. $("._button")
  80. .css("color", "#666")
  81. .css("text-shadow", "none")
  82. .css("background-color", "#f4f4e7");
  83. }
  84. },
  85. })
  86. }
  87.  
  88. // ajaxでお気に入り登録する関数
  89. function follow() {
  90. var usr_id = $(".user-link").attr("href");
  91. var usrid = usr_id.match(/\/member.php\?id=([0-9]+)/);
  92. var id = usrid[1];
  93.  
  94. var tt = $("input[name=tt]").val();
  95.  
  96. $.ajax({
  97. url: 'http://www.pixiv.net/bookmark_add.php',
  98. type: 'POST',
  99. dataType: 'json',
  100. data: {
  101. mode: "add",
  102. type: "user",
  103. user_id: id,
  104. tt: tt,
  105. from_sid: "",
  106. restrict: follow_restrict,
  107. left_column: "OK",
  108. success: function() {
  109. $("i._icon sprites-follow")
  110. .removeClass("_icon sprites-follow")
  111. .addClass("_icon sprites-follow");
  112. }
  113. },
  114. })
  115. }
  116.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址