Pixiv ajax bookmark mod

You can bookmark without going to the related pages. ページ遷移なく非同期的にブックマークします。

当前为 2017-10-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pixiv ajax bookmark mod
  3. // @namespace
  4. // @version 1.8.0
  5. // @description You can bookmark without going to the related pages. ページ遷移なく非同期的にブックマークします。
  6. // @include http://www.pixiv.net/member_illust.php*
  7. // @include https://www.pixiv.net/member_illust.php*
  8. // @exclude http://www.pixiv.net/member*mode=manga*
  9. // @exclude https://www.pixiv.net/member*mode=manga*
  10. // @copyright 2014+, qa2
  11. // @author qa2 & SaddestPanda
  12. // @grant none
  13. // @namespace
  14. // ==/UserScript==
  15.  
  16. //When you add an illustration to bookmarks also give it a like.
  17. // 1 でしたらブックマークした時、同時に「いいね!」もします。
  18. var givelike = 1;
  19.  
  20. //R18 illustrations are added as private bookmarks.
  21. // 1 でしたらイラストはR-18であった場合プライベートブックマークにします。
  22. var r18private = 1;
  23.  
  24. // If set to "1": Always add to private bookmarks list.
  25. //ブックマークする作品をいつも非公開にするかどうか 0:公開 1:非公開
  26. var bkm_restrict = 0;
  27.  
  28. //Add all tags to the bookmark.
  29. //作品に登録されているすべてのタグをブックマークタグとして追加
  30. var tags = "";
  31. $(".tag > .text").each(function() {
  32. tags += $(this).text() + " ";
  33. });
  34.  
  35.  
  36. $(".add-bookmark").on("click", function(){
  37. //e.preventDefault();
  38. bkm();
  39. return false;
  40. });
  41.  
  42.  
  43. //Keybindings from the old script. Maybe you want these.
  44. /*
  45.  
  46. //eキーを押すとブクマする
  47. //press e to bookmark
  48. $(window).keydown(function(e) {
  49. if (!$("input[name=word]").is(":focus") && e.which == 69) {
  50. bkm();
  51. }
  52. });
  53.  
  54. //press R to private bookmark
  55. $(window).keydown(function(e) {
  56. if (!$("input[name=word]").is(":focus") && e.which == 82) {
  57. bkm_restrict = 1;
  58. bkm();
  59. }
  60. });
  61.  
  62. */
  63.  
  64. // ajaxでブックマークする関数
  65. function bkm() {
  66.  
  67. //var illustid = $("input[name=illust_id").val();
  68. //var tt = $("input[name=tt]").val();
  69. //var type = $("input[name=type]:eq(1)").val();
  70. var illustid = pixiv.context.illustId;
  71. var url = "https://www.pixiv.net/bookmark_add.php?id=" + illustid;
  72. var tt = pixiv.context.token;
  73. var type = pixiv.context.type;
  74.  
  75. if ($(".r-18")[0] != null && r18private) {
  76. bkm_restrict = 1;
  77. }
  78.  
  79. $.ajax({
  80. url: url,
  81. type: 'POST',
  82. dataType: 'json',
  83. data: {
  84. mode: "add",
  85. tt: tt,
  86. id: illustid,
  87. type: type,
  88. //from_sid: "",
  89. comment: "",
  90. tag: tags,
  91. restrict: bkm_restrict,
  92. success: function() {
  93. if ($(".add-bookmark").text() == "ブックマークに追加") {
  94. $(".add-bookmark").text("ブックマークを編集");
  95. } else {
  96. $(".add-bookmark").text("Edit Bookmark");
  97. }
  98. $(".add-bookmark")[0].classList.add("edit-bookmark");
  99. $(".add-bookmark")[0].classList.add("bookmarked");
  100. $(".edit-bookmark")[0].classList.remove("add-bookmark");
  101. $(".edit-bookmark").off("click");
  102. $(".edit-bookmark").css("font-weight","bolder");
  103. }
  104. },
  105. });
  106.  
  107. if (givelike) {
  108. $("._nice-button").trigger("click");
  109. }
  110. }
  111.