Blob.js

获取小红书个人信息页面数据点赞数据

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/475887/1254573/Blobjs.js

  1. // ==UserScript==
  2. // @name Blob.js
  3. // @run-at document-start
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.5
  6. // @description 获取小红书个人信息页面数据点赞数据
  7. // @author choukin
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11. /* eslint-disable */
  12. /* Blob.js*/
  13.  
  14. /*global self, unescape */
  15. /*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
  16. plusplus: true */
  17.  
  18. /*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
  19.  
  20. (function (view) {
  21. "use strict";
  22. view.URL = view.URL || view.webkitURL;
  23. if (view.Blob && view.URL) {
  24. try {
  25. new Blob;
  26. return;
  27. } catch (e) {
  28. }
  29. }
  30. // Internally we use a BlobBuilder implementation to base Blob off of
  31. // in order to support older browsers that only have BlobBuilder
  32. var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function (view) {
  33. var
  34. get_class = function (object) {
  35. return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
  36. }
  37. , FakeBlobBuilder = function BlobBuilder() {
  38. this.data = [];
  39. }
  40. , FakeBlob = function Blob(data, type, encoding) {
  41. this.data = data;
  42. this.size = data.length;
  43. this.type = type;
  44. this.encoding = encoding;
  45. }
  46. , FBB_proto = FakeBlobBuilder.prototype
  47. , FB_proto = FakeBlob.prototype
  48. , FileReaderSync = view.FileReaderSync
  49. , FileException = function (type) {
  50. this.code = this[this.name = type];
  51. }
  52. , file_ex_codes = (
  53. "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
  54. + "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
  55. ).split(" ")
  56. , file_ex_code = file_ex_codes.length
  57. , real_URL = view.URL || view.webkitURL || view
  58. , real_create_object_URL = real_URL.createObjectURL
  59. , real_revoke_object_URL = real_URL.revokeObjectURL
  60. , URL = real_URL
  61. , btoa = view.btoa
  62. , atob = view.atob
  63. , ArrayBuffer = view.ArrayBuffer
  64. , Uint8Array = view.Uint8Array
  65. , origin = /^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/
  66. ;
  67. FakeBlob.fake = FB_proto.fake = true;
  68. while (file_ex_code--) {
  69. FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
  70. }
  71. // Polyfill URL
  72. if (!real_URL.createObjectURL) {
  73. URL = view.URL = function (uri) {
  74. var
  75. uri_info = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
  76. , uri_origin
  77. ;
  78. uri_info.href = uri;
  79. if (!("origin" in uri_info)) {
  80. if (uri_info.protocol.toLowerCase() === "data:") {
  81. uri_info.origin = null;
  82. } else {
  83. uri_origin = uri.match(origin);
  84. uri_info.origin = uri_origin && uri_origin[1];
  85. }
  86. }
  87. return uri_info;
  88. };
  89. }
  90. URL.createObjectURL = function (blob) {
  91. var
  92. type = blob.type
  93. , data_URI_header
  94. ;
  95. if (type === null) {
  96. type = "application/octet-stream";
  97. }
  98. if (blob instanceof FakeBlob) {
  99. data_URI_header = "data:" + type;
  100. if (blob.encoding === "base64") {
  101. return data_URI_header + ";base64," + blob.data;
  102. } else if (blob.encoding === "URI") {
  103. return data_URI_header + "," + decodeURIComponent(blob.data);
  104. }
  105. if (btoa) {
  106. return data_URI_header + ";base64," + btoa(blob.data);
  107. } else {
  108. return data_URI_header + "," + encodeURIComponent(blob.data);
  109. }
  110. } else if (real_create_object_URL) {
  111. return real_create_object_URL.call(real_URL, blob);
  112. }
  113. };
  114. URL.revokeObjectURL = function (object_URL) {
  115. if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
  116. real_revoke_object_URL.call(real_URL, object_URL);
  117. }
  118. };
  119. FBB_proto.append = function (data/*, endings*/) {
  120. var bb = this.data;
  121. // decode data to a binary string
  122. if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
  123. var
  124. str = ""
  125. , buf = new Uint8Array(data)
  126. , i = 0
  127. , buf_len = buf.length
  128. ;
  129. for (; i < buf_len; i++) {
  130. str += String.fromCharCode(buf[i]);
  131. }
  132. bb.push(str);
  133. } else if (get_class(data) === "Blob" || get_class(data) === "File") {
  134. if (FileReaderSync) {
  135. var fr = new FileReaderSync;
  136. bb.push(fr.readAsBinaryString(data));
  137. } else {
  138. // async FileReader won't work as BlobBuilder is sync
  139. throw new FileException("NOT_READABLE_ERR");
  140. }
  141. } else if (data instanceof FakeBlob) {
  142. if (data.encoding === "base64" && atob) {
  143. bb.push(atob(data.data));
  144. } else if (data.encoding === "URI") {
  145. bb.push(decodeURIComponent(data.data));
  146. } else if (data.encoding === "raw") {
  147. bb.push(data.data);
  148. }
  149. } else {
  150. if (typeof data !== "string") {
  151. data += ""; // convert unsupported types to strings
  152. }
  153. // decode UTF-16 to binary string
  154. bb.push(unescape(encodeURIComponent(data)));
  155. }
  156. };
  157. FBB_proto.getBlob = function (type) {
  158. if (!arguments.length) {
  159. type = null;
  160. }
  161. return new FakeBlob(this.data.join(""), type, "raw");
  162. };
  163. FBB_proto.toString = function () {
  164. return "[object BlobBuilder]";
  165. };
  166. FB_proto.slice = function (start, end, type) {
  167. var args = arguments.length;
  168. if (args < 3) {
  169. type = null;
  170. }
  171. return new FakeBlob(
  172. this.data.slice(start, args > 1 ? end : this.data.length)
  173. , type
  174. , this.encoding
  175. );
  176. };
  177. FB_proto.toString = function () {
  178. return "[object Blob]";
  179. };
  180. FB_proto.close = function () {
  181. this.size = 0;
  182. delete this.data;
  183. };
  184. return FakeBlobBuilder;
  185. }(view));
  186. view.Blob = function (blobParts, options) {
  187. var type = options ? (options.type || "") : "";
  188. var builder = new BlobBuilder();
  189. if (blobParts) {
  190. for (var i = 0, len = blobParts.length; i < len; i++) {
  191. if (Uint8Array && blobParts[i] instanceof Uint8Array) {
  192. builder.append(blobParts[i].buffer);
  193. }
  194. else {
  195. builder.append(blobParts[i]);
  196. }
  197. }
  198. }
  199. var blob = builder.getBlob(type);
  200. if (!blob.slice && blob.webkitSlice) {
  201. blob.slice = blob.webkitSlice;
  202. }
  203. return blob;
  204. };
  205. var getPrototypeOf = Object.getPrototypeOf || function (object) {
  206. return object.__proto__;
  207. };
  208. view.Blob.prototype = getPrototypeOf(new view.Blob());
  209. }(
  210. typeof self !== "undefined" && self
  211. || typeof window !== "undefined" && window
  212. || this
  213. ));