Pixiv Easyer

A script that makes pixiv great again

  1. // ==UserScript==
  2. // @name Pixiv Easyer
  3. // @namespace http://
  4. // @version 1.0
  5. // @description A script that makes pixiv great again
  6. // @author DriftKingTW(Pixiv ID:9934873)
  7. // @match http://www.pixiv.net/member_illust.php?mode=medium&illust_id=*
  8. // @match http://www.pixiv.net/member_illust.php?mode=manga&illust_id=*
  9. // @match http://www.pixiv.net/member.php?id=*
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. //sync test
  15. (function() {
  16. 'use strict';
  17.  
  18. var bmBtn = $('.bookmark-container a');
  19. var favBtn = $('#favorite-button');
  20. var favSubmit = $('input[name="left_column"]');
  21.  
  22. var tt = $('input[name="tt"]').val();
  23. var user_id = $('input[name="user_id"]').val();
  24.  
  25. if(bmBtn.attr('class')=='add-bookmark _button'){
  26. bmBtn.attr('href', 'javascript: void(0);');
  27. bmBtn.bind('click', ajaxBookmark);
  28. }
  29. if(favBtn.attr('class')=='follow'){
  30. favSubmit.attr('href', 'javascript: void(0);');
  31. favSubmit.attr('type', 'button');
  32. favSubmit.bind('click', ajaxFollowUser);
  33. }
  34.  
  35. function ajaxBookmark() {
  36. bmBtn.text(' Adding... ');
  37. // get data
  38. var id = $('input[name="illust_id"]').val();
  39. // sent ajax request
  40. $.ajax( {
  41. url: 'http://www.pixiv.net/bookmark_add.php',
  42. type: 'POST',
  43. data: {
  44. 'mode': 'add',
  45. 'tt': tt,
  46. 'id': id,
  47. 'type': 'illust',
  48. 'from_sid': '',
  49. 'comment': '',
  50. 'tag': '',
  51. 'restrict': 0
  52. },
  53. success: function(response) {
  54. bmBtn.text('Edit Bookmark').attr({ class: 'edit-bookmark button-on',
  55. href: 'http://www.pixiv.net/bookmark_add.php?type=illust&illust_id='+id });
  56. },
  57. error: function(xhr) {
  58. alert('ajax request failed!(((゚Д゚;)))');
  59. }
  60. });
  61. bmBtn.unbind('click', ajaxBookmark);
  62. }
  63.  
  64. function ajaxFollowUser() {
  65. favSubmit.val(' Adding... ');
  66. // sent ajax request
  67. $.ajax( {
  68. url: 'http://www.pixiv.net/bookmark_add.php',
  69. type: 'POST',
  70. data: {
  71. 'mode': 'add',
  72. 'type': 'user',
  73. 'user_id': user_id,
  74. 'tt': tt,
  75. 'from_sid': '',
  76. 'restrict': 0,
  77. 'left_column': 'OK'
  78. },
  79. success: function(response) {
  80. favSubmit.val('Followed');
  81. },
  82. error: function(xhr) {
  83. alert('ajax request failed!(((゚Д゚;)))');
  84. }
  85. });
  86. favSubmit.unbind('click', ajaxFollowUser);
  87. }
  88. })();