Pixiv View Util

閲覧専用のユーティリティです。(1)各イラストの閲覧ページや作者ごとの画像一覧ページのレイアウトを変更します。(2)pixivサイト内でポップアップ機能を有効化します。

  1. // ==UserScript==
  2. // @name Pixiv View Util
  3. // @name:en Pixiv View Util
  4. // @description 閲覧専用のユーティリティです。(1)各イラストの閲覧ページや作者ごとの画像一覧ページのレイアウトを変更します。(2)pixivサイト内でポップアップ機能を有効化します。
  5. // @description:en this is some utility funcitions for pixiv.(1)change the layout of illust pages and auther's pages. (2)add popup tool.
  6. // @namespace Pixiv View Util
  7. // @version 2.2.2-20191022
  8. // @author sotoba
  9. // @noframes
  10. // @homepageURL https://github.com/SotobatoNihu/PixivViewUtil
  11. // @license The MIT License
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/vuex/3.1.1/vuex.min.js
  14. // @require https://cdnjs.cloudflare.com/ajax/libs/vue-i18n/8.15.0/vue-i18n.min.js
  15. // @include https://www.pixiv.net/*
  16. // @grant GM_getValue
  17. // @grant GM.getValue
  18. // @grant GM_setValue
  19. // @grant GM.setValue
  20. // @grant GM.getResourceUrl
  21. // @grant GM_getResourceText
  22. // ==/UserScript==
  23.  
  24. (function (Vue, Vuex) {
  25. 'use strict';
  26.  
  27.  
  28. function __$styleInject( css ) {
  29. if(!css) return ;
  30.  
  31. if(typeof(window) == 'undefined') return ;
  32. let style = document.createElement('style');
  33.  
  34. style.innerHTML = css;
  35. document.head.appendChild(style);
  36. return css;
  37. }
  38.  
  39. Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
  40. Vuex = Vuex && Vuex.hasOwnProperty('default') ? Vuex['default'] : Vuex;
  41.  
  42. __$styleInject("\r\n");
  43.  
  44. var script = {
  45. name: 'PixivIcons',
  46. props: {
  47. icon: {
  48. default: 'like',
  49. type: String,
  50. },
  51. },
  52. };
  53. function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
  54. , shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
  55. if (typeof shadowMode !== 'boolean') {
  56. createInjectorSSR = createInjector;
  57. createInjector = shadowMode;
  58. shadowMode = false;
  59. }
  60. var options = typeof script === 'function' ? script.options : script;
  61. if (template && template.render) {
  62. options.render = template.render;
  63. options.staticRenderFns = template.staticRenderFns;
  64. options._compiled = true;
  65. if (isFunctionalTemplate) {
  66. options.functional = true;
  67. }
  68. }
  69. if (scopeId) {
  70. options._scopeId = scopeId;
  71. }
  72. var hook;
  73. if (moduleIdentifier) {
  74. hook = function hook(context) {
  75. context = context ||
  76. this.$vnode && this.$vnode.ssrContext ||
  77. this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
  78. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  79. context = __VUE_SSR_CONTEXT__;
  80. }
  81. if (style) {
  82. style.call(this, createInjectorSSR(context));
  83. }
  84. if (context && context._registeredComponents) {
  85. context._registeredComponents.add(moduleIdentifier);
  86. }
  87. };
  88. options._ssrRegister = hook;
  89. } else if (style) {
  90. hook = shadowMode ? function () {
  91. style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
  92. } : function (context) {
  93. style.call(this, createInjector(context));
  94. };
  95. }
  96. if (hook) {
  97. if (options.functional) {
  98. var originalRender = options.render;
  99. options.render = function renderWithStyleInjection(h, context) {
  100. hook.call(context);
  101. return originalRender(h, context);
  102. };
  103. } else {
  104. var existing = options.beforeCreate;
  105. options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
  106. }
  107. }
  108. return script;
  109. }
  110. var normalizeComponent_1 = normalizeComponent;
  111. const __vue_script__ = script;
  112. var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.icon === 'like')?_c('img',{attrs:{"src":"https://s.pximg.net/www/js/spa/e2b56a11e49a9eaaf6c26d75362bad8c.svg","width":"12","height":"12"}}):(_vm.icon === 'bookmark')?_c('svg',{attrs:{"viewBox":"0 0 12 12","width":"12","height":"12"}},[_c('path',{attrs:{"fill":"currentColor","d":"M9,0.75 C10.6568542,0.75 12,2.09314575 12,3.75 C12,6.68851315 10.0811423,9.22726429 6.24342696,11.3662534\n L6.24342863,11.3662564 C6.09210392,11.4505987 5.90790324,11.4505988 5.75657851,11.3662565\n C1.9188595,9.22726671 0,6.68851455 0,3.75 C1.1324993e-16,2.09314575 1.34314575,0.75 3,0.75\n C4.12649824,0.75 5.33911281,1.60202454 6,2.66822994 C6.66088719,1.60202454 7.87350176,0.75 9,0.75 Z"}})]):(_vm.icon === 'view')?_c('img',{attrs:{"src":"https://s.pximg.net/www/js/spa/64a1477160859eee079f02a55ccc9de3.svg","width":"14","height":"12"}}):_vm._e()};
  113. var __vue_staticRenderFns__ = [];
  114. const __vue_inject_styles__ = undefined;
  115. const __vue_scope_id__ = undefined;
  116. const __vue_module_identifier__ = undefined;
  117. const __vue_is_functional_template__ = false;
  118. var PixivIcons = normalizeComponent_1(
  119. { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
  120. __vue_inject_styles__,
  121. __vue_script__,
  122. __vue_scope_id__,
  123. __vue_is_functional_template__,
  124. __vue_module_identifier__,
  125. undefined,
  126. undefined
  127. );
  128. var script$1 = {
  129. name: 'Caption',
  130. components: {
  131. PixivIcons,
  132. },
  133. props: {
  134. id: {
  135. default: 'popup-caption',
  136. type: String,
  137. },
  138. },
  139. data() {
  140. return {
  141. captionWidth: 100,
  142. };
  143. },
  144. computed: {
  145. tagArray() {
  146. const json = this.$store.state.pixivJson;
  147. return json.body.tags.tags;
  148. },
  149. captionHtml() {
  150. const json = this.$store.state.pixivJson;
  151. return json.body.description;
  152. },
  153. date() {
  154. const json = this.$store.state.pixivJson;
  155. const date = new Date(json.body.createDate);
  156. return `upload:${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`;
  157. },
  158. like() {
  159. const json = this.$store.state.pixivJson;
  160. return ` ${json.body.likeCount} `;
  161. },
  162. bookmark() {
  163. const json = this.$store.state.pixivJson;
  164. return ` ${json.body.bookmarkCount} `;
  165. },
  166. view() {
  167. const json = this.$store.state.pixivJson;
  168. return `${json.body.viewCount}`;
  169. },
  170. toggleCaption: function() {
  171. this.$store.commit('toggleCaption');
  172. return false;
  173. },
  174. captionStyle: function() {
  175. return {
  176. width: `${this.$store.state.screen.width + 10}px`,
  177. height: 'auto',
  178. display: 'block',
  179. backgroundColor: 'white',
  180. border: '1px solid #000',
  181. };
  182. },
  183. },
  184. updated: function() {
  185. this.$nextTick(function() {
  186. this.$store.commit('captionHeight', this.$el.clientHeight);
  187. });
  188. },
  189. };
  190. var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
  191. function createInjector(context) {
  192. return function (id, style) {
  193. return addStyle(id, style);
  194. };
  195. }
  196. var HEAD;
  197. var styles = {};
  198. function addStyle(id, css) {
  199. var group = isOldIE ? css.media || 'default' : id;
  200. var style = styles[group] || (styles[group] = {
  201. ids: new Set(),
  202. styles: []
  203. });
  204. if (!style.ids.has(id)) {
  205. style.ids.add(id);
  206. var code = css.source;
  207. if (css.map) {
  208. code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
  209. code += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + ' */';
  210. }
  211. if (!style.element) {
  212. style.element = document.createElement('style');
  213. style.element.type = 'text/css';
  214. if (css.media) style.element.setAttribute('media', css.media);
  215. if (HEAD === undefined) {
  216. HEAD = document.head || document.getElementsByTagName('head')[0];
  217. }
  218. HEAD.appendChild(style.element);
  219. }
  220. if ('styleSheet' in style.element) {
  221. style.styles.push(code);
  222. style.element.styleSheet.cssText = style.styles.filter(Boolean).join('\n');
  223. } else {
  224. var index = style.ids.size - 1;
  225. var textNode = document.createTextNode(code);
  226. var nodes = style.element.childNodes;
  227. if (nodes[index]) style.element.removeChild(nodes[index]);
  228. if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
  229. }
  230. }
  231. }
  232. var browser = createInjector;
  233. const __vue_script__$1 = script$1;
  234. var __vue_render__$1 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{style:(_vm.captionStyle),attrs:{"id":_vm.id}},[_c('div',{staticClass:"description",domProps:{"innerHTML":_vm._s(_vm.captionHtml)}}),_vm._v(" "),_c('div',{staticClass:"appendum"},[_c('div',{staticClass:"tags",staticStyle:{"display":"inline-block"}},_vm._l((_vm.tagArray),function(tagElem){return _c('span',[(tagElem.locked)?_c('span',[_vm._v("*")]):_vm._e(),_c('a',{attrs:{"href":"https://dic.pixiv.net/a/{{tagElem.tag}}"}},[_vm._v(_vm._s(tagElem.tag)),_c('span',{class:[ ( tagElem.romaji || tagElem.locked ) ? 'pixpedia-icon' : _vm.pixpedia-_vm.no-_vm.icon ]})])])}),0),_vm._v(" "),_c('div',{staticClass:"information"},[_c('div',{domProps:{"textContent":_vm._s(_vm.date)}}),_vm._v(" "),_c('PixivIcons',{attrs:{"icon":'like'}}),_vm._v(" "),_c('span',{staticClass:"like",domProps:{"textContent":_vm._s(_vm.like)}}),_vm._v(" "),_c('PixivIcons',{attrs:{"icon":'bookmark'}}),_vm._v(" "),_c('span',{attrs:{"id":"bookmark"},domProps:{"textContent":_vm._s(_vm.bookmark)}}),_vm._v(" "),_c('PixivIcons',{attrs:{"icon":'view'}}),_vm._v(" "),_c('span',{attrs:{"id":"view"},domProps:{"textContent":_vm._s(_vm.view)}})],1)])])};
  235. var __vue_staticRenderFns__$1 = [];
  236. const __vue_inject_styles__$1 = function (inject) {
  237. if (!inject) return
  238. inject("data-v-75b42063_0", { source: ".description[data-v-75b42063]{white-space:pre-line;z-index:10001;word-wrap:break-word;width:auto;height:70%;max-height:70%;overflow-y:scroll;scrollbar-width:thin}.appendum[data-v-75b42063]{width:auto;height:auto;max-height:30%;overflow-y:scroll}.information[data-v-75b42063]{background-color:#fff;font-size:x-small;width:auto;height:auto;max-height:20%;color:#999;line-height:1}.pixpedia-icon[data-v-75b42063]{display:inline-block;margin-left:2px;width:15px;height:14px;vertical-align:-2px;text-decoration:none;background:url(https://s.pximg.net/www/images/inline/pixpedia.png) no-repeat}.pixpedia-no-icon[data-v-75b42063]{display:inline-block;margin-left:2px;width:15px;height:14px;vertical-align:-2px;text-decoration:none;background:url(https://s.pximg.net/www/images/inline/pixpedia-no-item.png) no-repeat}", map: undefined, media: undefined });
  239. };
  240. const __vue_scope_id__$1 = "data-v-75b42063";
  241. const __vue_module_identifier__$1 = undefined;
  242. const __vue_is_functional_template__$1 = false;
  243. var Caption = normalizeComponent_1(
  244. { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
  245. __vue_inject_styles__$1,
  246. __vue_script__$1,
  247. __vue_scope_id__$1,
  248. __vue_is_functional_template__$1,
  249. __vue_module_identifier__$1,
  250. browser,
  251. undefined
  252. );
  253. var script$2 = {
  254. name: 'Screen',
  255. props: {
  256. id: 'popup-screen',
  257. },
  258. data() {
  259. return {
  260. width: 1000,
  261. height: 1000,
  262. };
  263. },
  264. computed: {
  265. screenImg: function() {
  266. return this.$store.state.pixivJson.body.urls.regular;
  267. },
  268. getSize: function() {
  269. const imgWidth = this.$store.state.pixivJson.body.width;
  270. const imgHeight = this.$store.state.pixivJson.body.height;
  271. const wscale = (window.innerWidth * this.$store.state.screen.scale) / imgWidth;
  272. const hscale = (window.innerHeight * this.$store.state.screen.scale) / imgHeight;
  273. const scale = wscale < hscale ? wscale : hscale;
  274. const _height = imgHeight * scale;
  275. const _width = imgWidth * scale;
  276. this.$store.commit('screenWidth', _width);
  277. this.$store.commit('screenHeight', _height );
  278. return { height: _height, width: _width };
  279. },
  280. imgStyle: function() {
  281. const size = this.getSize;
  282. return {
  283. width: 'auto',
  284. height: 'auto',
  285. pointerEvents: 'none',
  286. maxWidth: `${size.width}px`,
  287. maxHeight: `${size.height}px`,
  288. };
  289. },
  290. screenStyle: function() {
  291. const size = this.getSize;
  292. return {
  293. border: '5px solid black',
  294. backgroundColor: '#111',
  295. position: 'relative',
  296. width: 'auto',
  297. height: 'auto',
  298. maxWidth: `${size.width}px`,
  299. maxHeight: `${size.height}px`,
  300. float: 'left',
  301. backgroundImage: `url(${this.screenImg})`,
  302. backgroundSize: 'contain',
  303. backgroundPosition: 'center',
  304. backgroundRepeat: 'no-repeat',
  305. };
  306. },
  307. },
  308. updated() {
  309. this.$nextTick(function() {
  310. this.$store.commit('screenLoaded');
  311. });
  312. },
  313. };
  314. const __vue_script__$2 = script$2;
  315. var __vue_render__$2 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{style:(_vm.screenStyle),attrs:{"id":_vm.id}},[_c('img',{style:(_vm.imgStyle),attrs:{"src":_vm.screenImg}})])};
  316. var __vue_staticRenderFns__$2 = [];
  317. const __vue_inject_styles__$2 = undefined;
  318. const __vue_scope_id__$2 = "data-v-25a9257f";
  319. const __vue_module_identifier__$2 = undefined;
  320. const __vue_is_functional_template__$2 = false;
  321. var Screen = normalizeComponent_1(
  322. { render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
  323. __vue_inject_styles__$2,
  324. __vue_script__$2,
  325. __vue_scope_id__$2,
  326. __vue_is_functional_template__$2,
  327. __vue_module_identifier__$2,
  328. undefined,
  329. undefined
  330. );
  331. var script$3 = {
  332. name: "Illust",
  333. mixins: [Screen],
  334. };
  335. const __vue_script__$3 = script$3;
  336. var __vue_render__$3 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{style:(_vm.screenStyle)},[_c('img',{style:(_vm.imgStyle),attrs:{"src":_vm.screenImg}})])};
  337. var __vue_staticRenderFns__$3 = [];
  338. const __vue_inject_styles__$3 = undefined;
  339. const __vue_scope_id__$3 = "data-v-804ad3fc";
  340. const __vue_module_identifier__$3 = undefined;
  341. const __vue_is_functional_template__$3 = false;
  342. var Illust = normalizeComponent_1(
  343. { render: __vue_render__$3, staticRenderFns: __vue_staticRenderFns__$3 },
  344. __vue_inject_styles__$3,
  345. __vue_script__$3,
  346. __vue_scope_id__$3,
  347. __vue_is_functional_template__$3,
  348. __vue_module_identifier__$3,
  349. undefined,
  350. undefined
  351. );
  352. var script$4 = {
  353. name: "Manga",
  354. mixins: [Screen],
  355. data() {
  356. return {
  357. width: 1000,
  358. height: 1000,
  359. scrollWidth: 0,
  360. active: false,
  361. onmouse: false,
  362. };
  363. },
  364. computed: {
  365. ImageUrls: function() {
  366. let imgElemArray = [];
  367. const json = this.$store.state.pixivJson;
  368. const firstPageURL = json.body.urls.regular.replace(/\/...x...\//, '/600x600/');
  369. const pageNum = json.body.pageCount;
  370. for (let i = 0; i < pageNum; i++) {
  371. const url = firstPageURL.replace('p0', 'p' + i);
  372. imgElemArray.push(url);
  373. }
  374. return imgElemArray;
  375. },
  376. getHeight: function() {
  377. const store = this.$store;
  378. const height = window.innerHeight * this.$store.state.screen.scale;
  379. store.commit('screenHeight', height);
  380. return height;
  381. },
  382. getWidth: function() {
  383. const store = this.$store;
  384. const width = window.innerWidth * this.$store.state.screen.scale;
  385. store.commit('screenWidth', width);
  386. return width;
  387. },
  388. getSize: function() {
  389. this.height = window.innerHeight * this.$store.state.screen.scale;
  390. this.width = window.innerWidth * this.$store.state.screen.scale;
  391. this.$store.commit('screenWidth', this.width);
  392. this.$store.commit('screenHeight', this.height);
  393. return { width: this.width, height: this.height };
  394. },
  395. mangaStyle: function() {
  396. const size = this.getSize;
  397. return {
  398. border: '5px solid black',
  399. backgroundColor: '#111',
  400. position: 'relative',
  401. whiteSpace: 'nowrap',
  402. width: '100%',
  403. height: 'auto',
  404. maxWidth: `${size.width}px`,
  405. maxHeight: `${size.height + 17}px`,
  406. float: 'left',
  407. overflow: 'hidden',
  408. backgroundSize: 'contain',
  409. backgroundPosition: 'center',
  410. backgroundRepeat: 'no-repeat',
  411. };
  412. },
  413. thumbStyle: function() {
  414. return {
  415. left: `${this.scrollWidth}px`,
  416. };
  417. },
  418. },
  419. watch: {
  420. scrollWidth: function() {
  421. this.$refs.scrollable.scrollLeft = this.scrollWidth;
  422. },
  423. },
  424. updated: {},
  425. mounted() {
  426. const store = this.$store;
  427. const wrapper = this.$refs.wrapper;
  428. let onmouse = this.onmouse;
  429. wrapper.addEventListener('scroll', function(event) {
  430. store.state.screen.dragging = true;
  431. return false;
  432. });
  433. wrapper.addEventListener('mouseover', function(event) {
  434. onmouse = true;
  435. });
  436. wrapper.addEventListener('mouseout', function(event) {
  437. onmouse = false;
  438. });
  439. wrapper.addEventListener('mousemove', function(event) {
  440. onmouse = true;
  441. });
  442. wrapper.addEventListener('wheel', function(event) {
  443. onmouse = true;
  444. });
  445. document.addEventListener('wheel', function(event) {
  446. if (event.target.id === 'manga__main' || onmouse) {
  447. event.preventDefault();
  448. const scrollValue = event.deltaY > 0 ? 100 : -100;
  449. wrapper.scrollBy(scrollValue, 0);
  450. }
  451. });
  452. },
  453. methods: {},
  454. };
  455. const __vue_script__$4 = script$4;
  456. var __vue_render__$4 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{style:(_vm.mangaStyle),attrs:{"id":_vm.id}},[_c('div',{ref:"wrapper",staticClass:"scroll_wrapper"},[_c('div',{ref:"scrollable",attrs:{"id":"manga__main"}},_vm._l((_vm.ImageUrls),function(imgUrl){return _c('img',{key:_vm.number,style:(_vm.imgStyle),attrs:{"src":imgUrl}})}),0)])])};
  457. var __vue_staticRenderFns__$4 = [];
  458. const __vue_inject_styles__$4 = function (inject) {
  459. if (!inject) return
  460. inject("data-v-54943c6f_0", { source: ".scroll_wrapper[data-v-54943c6f]{height:calc(100% - 17px);width:100%;overflow-x:scroll;-webkit-overflow-scrolling:touch}", map: undefined, media: undefined });
  461. };
  462. const __vue_scope_id__$4 = "data-v-54943c6f";
  463. const __vue_module_identifier__$4 = undefined;
  464. const __vue_is_functional_template__$4 = false;
  465. var Manga = normalizeComponent_1(
  466. { render: __vue_render__$4, staticRenderFns: __vue_staticRenderFns__$4 },
  467. __vue_inject_styles__$4,
  468. __vue_script__$4,
  469. __vue_scope_id__$4,
  470. __vue_is_functional_template__$4,
  471. __vue_module_identifier__$4,
  472. browser,
  473. undefined
  474. );
  475. var ZipImagePlayer = (function() {
  476. function base64ArrayBuffer(arrayBuffer, off, byteLength) {
  477. let base64 = '';
  478. const encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  479. const bytes = new Uint8Array(arrayBuffer);
  480. const byteRemainder = byteLength % 3;
  481. const mainLength = off + byteLength - byteRemainder;
  482. let a, b, c, d;
  483. let chunk;
  484. for (let i = off; i < mainLength; i = i + 3) {
  485. chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
  486. a = (chunk & 16515072) >> 18;
  487. b = (chunk & 258048) >> 12;
  488. c = (chunk & 4032) >> 6;
  489. d = chunk & 63;
  490. base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d];
  491. }
  492. if (byteRemainder == 1) {
  493. chunk = bytes[mainLength];
  494. a = (chunk & 252) >> 2;
  495. b = (chunk & 3) << 4;
  496. base64 += `${encodings[a] + encodings[b]}==`;
  497. } else if (byteRemainder == 2) {
  498. chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1];
  499. a = (chunk & 64512) >> 10;
  500. b = (chunk & 1008) >> 4;
  501. c = (chunk & 15) << 2;
  502. base64 += `${encodings[a] + encodings[b] + encodings[c]}=`;
  503. }
  504. return base64;
  505. }
  506. class ZipImagePlayer {
  507. constructor(options) {
  508. this.op = options;
  509. this._rescale = false;
  510. this._URL = (window.URL || window.webkitURL || window.MozURL
  511. || window.MSURL);
  512. this._Blob = (window.Blob || window.WebKitBlob || window.MozBlob
  513. || window.MSBlob);
  514. this._BlobBuilder = (window.BlobBuilder || window.WebKitBlobBuilder
  515. || window.MozBlobBuilder || window.MSBlobBuilder);
  516. this._Uint8Array = (window.Uint8Array || window.WebKitUint8Array
  517. || window.MozUint8Array || window.MSUint8Array);
  518. this._DataView = (window.DataView || window.WebKitDataView
  519. || window.MozDataView || window.MSDataView);
  520. this._ArrayBuffer = (window.ArrayBuffer || window.WebKitArrayBuffer
  521. || window.MozArrayBuffer || window.MSArrayBuffer);
  522. this._maxLoadAhead = 0;
  523. if (!this._URL) {
  524. this._debugLog("No URL support! Will use slower data: URLs.");
  525. this._maxLoadAhead = 10;
  526. }
  527. if (!this._Blob) {
  528. this._error("No Blob support");
  529. }
  530. if (!this._Uint8Array) {
  531. this._error("No Uint8Array support");
  532. }
  533. if (!this._DataView) {
  534. this._error("No DataView support");
  535. }
  536. if (!this._ArrayBuffer) {
  537. this._error("No ArrayBuffer support");
  538. }
  539. this._isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
  540. this._loadingState = 0;
  541. this._dead = false;
  542. this._context = options.canvas.getContext("2d");
  543. this._files = {};
  544. this._frameCount = this.op.metadata.frames.length;
  545. this._trailerBytes = 30000;
  546. this._failed = false;
  547. this._debugLog(`Frame count: ${this._frameCount}`);
  548. this._frame = 0;
  549. this._loadFrame = 0;
  550. this._frameImages = [];
  551. this._paused = false;
  552. this._loadTimer = null;
  553. this._startLoad();
  554. if (this.op.autoStart) {
  555. this.play();
  556. }
  557. else {
  558. this._paused = true;
  559. }
  560. }
  561. _mkerr(msg) {
  562. return () => {
  563. this._error(msg);
  564. };
  565. }
  566. _error(msg) {
  567. this._failed = true;
  568. throw Error(`ZipImagePlayer error: ${msg}`);
  569. }
  570. _debugLog(msg) {
  571. if (this.op.debug) {
  572. console.log(msg);
  573. }
  574. }
  575. _load(offset, length, callback) {
  576. const xhr = new XMLHttpRequest();
  577. xhr.addEventListener("load", () => {
  578. if (this._dead) {
  579. return;
  580. }
  581. this._debugLog(`Load: ${offset} ${length} status=${xhr.status}`);
  582. if (xhr.status == 200) {
  583. this._debugLog("Range disabled or unsupported, complete load");
  584. offset = 0;
  585. length = xhr.response.byteLength;
  586. this._len = length;
  587. this._buf = xhr.response;
  588. this._bytes = new this._Uint8Array(this._buf);
  589. } else {
  590. if (xhr.status != 206) {
  591. this._error(`Unexpected HTTP status ${xhr.status}`);
  592. }
  593. if (xhr.response.byteLength != length) {
  594. this._error(`Unexpected length ${xhr.response.byteLength} (expected ${length})`);
  595. }
  596. this._bytes.set(new this._Uint8Array(xhr.response), offset);
  597. }
  598. if (callback) {
  599. callback.apply(this, [offset, length]);
  600. }
  601. }, false);
  602. xhr.addEventListener("error", this._mkerr("Fetch failed"), false);
  603. xhr.open("GET", this.op.source);
  604. xhr.responseType = "arraybuffer";
  605. if (offset != null && length != null) {
  606. const end = offset + length;
  607. xhr.setRequestHeader("Range", `bytes=${offset}-${(end - 1)}`);
  608. if (this._isSafari) {
  609. xhr.setRequestHeader("Cache-control", "no-cache");
  610. xhr.setRequestHeader("If-None-Match", Math.random().toString());
  611. }
  612. }
  613. xhr.send();
  614. }
  615. _startLoad() {
  616. if (!this.op.source) {
  617. this._loadNextFrame();
  618. return;
  619. }
  620. fetch(this.op.source, {
  621. method: "HEAD",
  622. }).then(resp => {
  623. if (this._dead) {
  624. return;
  625. }
  626. this._pHead = 0;
  627. this._pNextHead = 0;
  628. this._pFetch = 0;
  629. const len = parseInt(resp.headers.get("Content-Length"));
  630. if (!len) {
  631. this._debugLog("HEAD request failed: invalid file length.");
  632. this._debugLog("Falling back to full file mode.");
  633. this._load(null, null, (off, len) => {
  634. this._pTail = 0;
  635. this._pHead = len;
  636. this._findCentralDirectory();
  637. });
  638. return;
  639. }
  640. this._debugLog(`Len: ${len}`);
  641. this._len = len;
  642. this._buf = new this._ArrayBuffer(len);
  643. this._bytes = new this._Uint8Array(this._buf);
  644. let off = len - this._trailerBytes;
  645. if (off < 0) {
  646. off = 0;
  647. }
  648. this._pTail = len;
  649. this._load(off, len - off, (off) => {
  650. this._pTail = off;
  651. this._findCentralDirectory();
  652. });
  653. }).catch(this._mkerr("Length fetch failed"));
  654. }
  655. _findCentralDirectory() {
  656. const dv = new this._DataView(this._buf, this._len - 22, 22);
  657. if (dv.getUint32(0, true) != 0x06054b50) {
  658. this._error("End of Central Directory signature not found");
  659. }
  660. const cd_count = dv.getUint16(10, true);
  661. const cd_size = dv.getUint32(12, true);
  662. const cd_off = dv.getUint32(16, true);
  663. if (cd_off < this._pTail) {
  664. this._load(cd_off, this._pTail - cd_off, () => {
  665. this._pTail = cd_off;
  666. this._readCentralDirectory(cd_off, cd_size, cd_count);
  667. });
  668. } else {
  669. this._readCentralDirectory(cd_off, cd_size, cd_count);
  670. }
  671. }
  672. _readCentralDirectory(offset, size, count) {
  673. const dv = new this._DataView(this._buf, offset, size);
  674. let p = 0;
  675. for (let i = 0; i < count; i++ ) {
  676. if (dv.getUint32(p, true) != 0x02014b50) {
  677. this._error("Invalid Central Directory signature");
  678. }
  679. const compMethod = dv.getUint16(p + 10, true);
  680. const uncompSize = dv.getUint32(p + 24, true);
  681. const nameLen = dv.getUint16(p + 28, true);
  682. const extraLen = dv.getUint16(p + 30, true);
  683. const cmtLen = dv.getUint16(p + 32, true);
  684. const off = dv.getUint32(p + 42, true);
  685. if (compMethod != 0) {
  686. this._error("Unsupported compression method");
  687. }
  688. p += 46;
  689. const nameView = new this._Uint8Array(this._buf, offset + p, nameLen);
  690. let name = "";
  691. for (let j = 0; j < nameLen; j++) {
  692. name += String.fromCharCode(nameView[j]);
  693. }
  694. p += nameLen + extraLen + cmtLen;
  695. this._files[name] = { off: off, len: uncompSize };
  696. }
  697. if (this._pHead >= this._pTail) {
  698. this._pHead = this._len;
  699. this._loadNextFrame();
  700. } else {
  701. this._loadNextChunk();
  702. this._loadNextChunk();
  703. }
  704. }
  705. _loadNextChunk() {
  706. if (this._pFetch >= this._pTail) {
  707. return;
  708. }
  709. const off = this._pFetch;
  710. let len = this.op.chunkSize;
  711. if (this._pFetch + len > this._pTail) {
  712. len = this._pTail - this._pFetch;
  713. }
  714. this._pFetch += len;
  715. this._load(off, len, () => {
  716. if (off == this._pHead) {
  717. if (this._pNextHead) {
  718. this._pHead = this._pNextHead;
  719. this._pNextHead = 0;
  720. } else {
  721. this._pHead = off + len;
  722. }
  723. if (this._pHead >= this._pTail) {
  724. this._pHead = this._len;
  725. }
  726. if (!this._loadTimer) {
  727. this._loadNextFrame();
  728. }
  729. } else {
  730. this._pNextHead = off + len;
  731. }
  732. this._loadNextChunk();
  733. });
  734. }
  735. _fileDataStart(offset) {
  736. const dv = new DataView(this._buf, offset, 30);
  737. const nameLen = dv.getUint16(26, true);
  738. const extraLen = dv.getUint16(28, true);
  739. return offset + 30 + nameLen + extraLen;
  740. }
  741. _isFileAvailable(name) {
  742. const info = this._files[name];
  743. if (!info) {
  744. this._error(`File ${name} not found in ZIP`);
  745. }
  746. if (this._pHead < (info.off + 30)) {
  747. return false;
  748. }
  749. return this._pHead >= (this._fileDataStart(info.off) + info.len);
  750. }
  751. _loadNextFrame() {
  752. if (this._dead) {
  753. return;
  754. }
  755. const frame = this._loadFrame;
  756. if (frame >= this._frameCount) {
  757. return;
  758. }
  759. const meta = this.op.metadata.frames[frame];
  760. if (!this.op.source) {
  761. this._loadFrame += 1;
  762. this._loadImage(frame, meta.file, false);
  763. return;
  764. }
  765. if (!this._isFileAvailable(meta.file)) {
  766. return;
  767. }
  768. this._loadFrame += 1;
  769. const off = this._fileDataStart(this._files[meta.file].off);
  770. const end = off + this._files[meta.file].len;
  771. let url;
  772. const mime_type = this.op.metadata.mime_type || "image/png";
  773. if (this._URL) {
  774. let slice;
  775. if (!this._buf.slice) {
  776. slice = new this._ArrayBuffer(this._files[meta.file].len);
  777. const view = new this._Uint8Array(slice);
  778. view.set(this._bytes.subarray(off, end));
  779. } else {
  780. slice = this._buf.slice(off, end);
  781. }
  782. let blob;
  783. try {
  784. blob = new this._Blob([slice], { type: mime_type });
  785. }
  786. catch (err) {
  787. this._debugLog(`${"Blob constructor failed. Trying BlobBuilder..."
  788. + " ("}${err.message})`);
  789. const bb = new this._BlobBuilder();
  790. bb.append(slice);
  791. blob = bb.getBlob();
  792. }
  793. url = this._URL.createObjectURL(blob);
  794. this._loadImage(frame, url, true);
  795. } else {
  796. url = (`data:${mime_type};base64,${
  797. base64ArrayBuffer(this._buf, off, end - off)}`);
  798. this._loadImage(frame, url, false);
  799. }
  800. }
  801. _loadImage(frame, url, isBlob) {
  802. const image = new Image();
  803. const meta = this.op.metadata.frames[frame];
  804. image.addEventListener('load', () => {
  805. this._debugLog(`Loaded ${meta.file} to frame ${frame}`);
  806. if (isBlob) {
  807. this._URL.revokeObjectURL(url);
  808. }
  809. if (this._dead) {
  810. return;
  811. }
  812. this._frameImages[frame] = image;
  813. if (this._loadingState == 0) {
  814. this._displayFrame.apply(this);
  815. }
  816. if (frame >= (this._frameCount - 1)) {
  817. this._setLoadingState(2);
  818. this._buf = null;
  819. this._bytes = null;
  820. } else {
  821. if (!this._maxLoadAhead ||
  822. (frame - this._frame) < this._maxLoadAhead) {
  823. this._loadNextFrame();
  824. } else if (!this._loadTimer) {
  825. this._loadTimer = setTimeout(() => {
  826. this._loadTimer = null;
  827. this._loadNextFrame();
  828. }, 200);
  829. }
  830. }
  831. });
  832. image.src = url;
  833. }
  834. _setLoadingState(state) {
  835. if (this._loadingState != state) {
  836. this._loadingState = state;
  837. }
  838. }
  839. _displayFrame() {
  840. if (this._dead) {
  841. return;
  842. }
  843. const meta = this.op.metadata.frames[this._frame];
  844. this._debugLog(`Displaying frame: ${this._frame} ${meta.file}`);
  845. const image = this._frameImages[this._frame];
  846. if (!image) {
  847. this._debugLog("Image not available!");
  848. this._setLoadingState(0);
  849. return;
  850. }
  851. if (this._loadingState != 2) {
  852. this._setLoadingState(1);
  853. }
  854. if (this.op.autoscale) {
  855. if (!this._rescale) {
  856. this._context.canvas.width = this.op.width;
  857. this._context.canvas.height = this.op.height;
  858. const scale = this.op.width / image.width;
  859. this._context.scale(scale, scale);
  860. this._rescale = true;
  861. }
  862. } else if (this.op.autosize) {
  863. if (this._context.canvas.width != image.width || this._context.canvas.height != image.height) {
  864. this._context.canvas.width = image.width;
  865. this._context.canvas.height = image.height;
  866. }
  867. }
  868. this._context.clearRect(0, 0, this.op.canvas.width,
  869. this.op.canvas.height);
  870. this._context.drawImage(image, 0, 0);
  871. if (!this._paused) {
  872. this._timer = setTimeout(() => {
  873. this._timer = null;
  874. this._nextFrame.apply(this);
  875. }, meta.delay);
  876. }
  877. }
  878. _nextFrame() {
  879. if (this._frame >= (this._frameCount - 1)) {
  880. if (this.op.loop) {
  881. this._frame = 0;
  882. } else {
  883. this.pause();
  884. return;
  885. }
  886. } else {
  887. this._frame += 1;
  888. }
  889. this._displayFrame();
  890. }
  891. play() {
  892. if (this._dead) {
  893. return;
  894. }
  895. if (this._paused) {
  896. this._paused = false;
  897. this._displayFrame();
  898. }
  899. }
  900. pause() {
  901. if (this._dead) {
  902. return;
  903. }
  904. if (!this._paused) {
  905. if (this._timer) {
  906. clearTimeout(this._timer);
  907. }
  908. this._paused = true;
  909. }
  910. }
  911. rewind() {
  912. if (this._dead) {
  913. return;
  914. }
  915. this._frame = 0;
  916. if (this._timer) {
  917. clearTimeout(this._timer);
  918. }
  919. this._displayFrame();
  920. }
  921. stop() {
  922. this._debugLog("Stopped!");
  923. this._dead = true;
  924. if (this._timer) {
  925. clearTimeout(this._timer);
  926. }
  927. if (this._loadTimer) {
  928. clearTimeout(this._loadTimer);
  929. }
  930. this._frameImages = null;
  931. this._buf = null;
  932. this._bytes = null;
  933. }
  934. getCurrentFrame() {
  935. return this._frame;
  936. }
  937. getLoadedFrames() {
  938. return this._frameImages.length;
  939. }
  940. getFrameCount() {
  941. return this._frameCount;
  942. }
  943. hasError() {
  944. return this._failed;
  945. }
  946. }
  947. return ZipImagePlayer;
  948. }());
  949. var script$5 = {
  950. name: 'Ugoira',
  951. mixins: [Screen],
  952. props: {
  953. id: 'popup-screen',
  954. visible: false,
  955. },
  956. data() {
  957. return {
  958. isVisible: this.visible,
  959. width: 600,
  960. height: 600,
  961. };
  962. },
  963. computed: {
  964. },
  965. watch: {
  966. visible: function() {
  967. if (this.visible) {
  968. console.log("ugoira start!");
  969. const size = this.getSize;
  970. const screen = document.getElementById('popup-ugoira');
  971. if (screen) {
  972. screen.innerText = '';
  973. this.canvas = document.createElement('canvas');
  974. this.canvas.id = 'ugoira-canvas';
  975. this.canvas.style.pointerEvents = 'none';
  976. screen.appendChild(this.canvas);
  977. }
  978. const options = {
  979. canvas: this.canvas,
  980. metadata: this.$store.state.ugoiraJson.body,
  981. source: this.$store.state.ugoiraJson.body.src,
  982. mime_type: this.$store.state.ugoiraJson.body.mime_type,
  983. chunkSize: 10000,
  984. loop: true,
  985. autoStart: false,
  986. autoscale: true,
  987. width: size.width,
  988. height: size.height,
  989. };
  990. this.player = new ZipImagePlayer(options);
  991. const player = this.player;
  992. player.play();
  993. } else {
  994. if (this.player) {
  995. this.player.stop();
  996. }
  997. this.canvas = null;
  998. }
  999. },
  1000. },
  1001. };
  1002. const __vue_script__$5 = script$5;
  1003. var __vue_render__$5 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{style:(_vm.screenStyle),attrs:{"id":"popup-ugoira"}},[_c('img',{style:(_vm.imgStyle),attrs:{"src":_vm.screenImg}})])};
  1004. var __vue_staticRenderFns__$5 = [];
  1005. const __vue_inject_styles__$5 = function (inject) {
  1006. if (!inject) return
  1007. inject("data-v-6d211b59_0", { source: "#ugoira-canvas[data-v-6d211b59]{width:100%;height:100%;position:absolute;top:0;left:0;right:0;bottom:0}", map: undefined, media: undefined });
  1008. };
  1009. const __vue_scope_id__$5 = "data-v-6d211b59";
  1010. const __vue_module_identifier__$5 = undefined;
  1011. const __vue_is_functional_template__$5 = false;
  1012. var Ugoira = normalizeComponent_1(
  1013. { render: __vue_render__$5, staticRenderFns: __vue_staticRenderFns__$5 },
  1014. __vue_inject_styles__$5,
  1015. __vue_script__$5,
  1016. __vue_scope_id__$5,
  1017. __vue_is_functional_template__$5,
  1018. __vue_module_identifier__$5,
  1019. browser,
  1020. undefined
  1021. );
  1022. let basicResponse = {
  1023. body: {
  1024. illustTitile: '',
  1025. createDate: '2000-12-31T15:00:00+00:00"',
  1026. illustType: 0,
  1027. width: 1080,
  1028. height: 1080,
  1029. likeCount: 0,
  1030. bookmarkCount: 0,
  1031. commentCount: 0,
  1032. pageCount: 1,
  1033. viewCount: 0,
  1034. urls: {
  1035. regular: '',
  1036. },
  1037. tags: {
  1038. tags: [
  1039. {
  1040. tag: "",
  1041. locked: false,
  1042. deletable: false,
  1043. romaji: "",
  1044. translation: {
  1045. en: "",
  1046. },
  1047. },
  1048. ],
  1049. },
  1050. },
  1051. };
  1052. let commentResponse = {
  1053. error: false,
  1054. message: "",
  1055. body: {
  1056. comments: [
  1057. {
  1058. userId: 0,
  1059. userName: "",
  1060. img: "",
  1061. id: "",
  1062. comment: "no comment",
  1063. stampId: null,
  1064. stampLink: null,
  1065. commentDate: "",
  1066. commentRootId: null,
  1067. commentParentId: null,
  1068. commentUserId: "",
  1069. replyToUserId: null,
  1070. replyToUserName: null,
  1071. editable: false,
  1072. hasReplies: false,
  1073. }
  1074. ],
  1075. },
  1076. };
  1077. let ugoiraResponse = {
  1078. error: false,
  1079. message: "",
  1080. body: {
  1081. src: "",
  1082. originalSrc: "",
  1083. mime_type: "",
  1084. frames: [
  1085. {
  1086. file: "000000.jpg",
  1087. delay: 100
  1088. }
  1089. ]
  1090. },
  1091. };
  1092. let commentElement = {
  1093. userId: 0,
  1094. userName: "",
  1095. img: "",
  1096. id: "",
  1097. comment: "no comment",
  1098. stampId: null,
  1099. stampLink: null,
  1100. commentDate: "",
  1101. commentRootId: null,
  1102. commentParentId: null,
  1103. commentUserId: "",
  1104. replyToUserId: null,
  1105. replyToUserName: null,
  1106. editable: false,
  1107. hasReplies: false,
  1108. };
  1109. let emoji = {
  1110. "(normal2)": 201,
  1111. "(shame2)": 202,
  1112. "(love2)": 203,
  1113. "(interesting2)": 204,
  1114. "(blush2)": 205,
  1115. "(fire2)": 206,
  1116. "(angry2)": 207,
  1117. "(shine2)": 208,
  1118. "(panic2)": 209,
  1119. "(normal3)": 301,
  1120. "(satisfaction3)": 302,
  1121. "(surprise3)": 303,
  1122. "(smile3)": 304,
  1123. "(shock3)": 305,
  1124. "(gaze3)": 306,
  1125. "(wink3)": 307,
  1126. "(happy3)": 308,
  1127. "(excited3)": 309,
  1128. "(love3)": 310,
  1129. "(normal4)": 401,
  1130. "(surprise4)": 402,
  1131. "(serious4)": 403,
  1132. "(love4)": 404,
  1133. "(shine4)": 405,
  1134. "(sweat4)": 406,
  1135. "(shame4)": 407,
  1136. "(sleep4)": 408,
  1137. "(normal)": 101,
  1138. "(surprise)": 102,
  1139. "(serious)": 103,
  1140. "(heaven)": 104,
  1141. "(happy)": 105,
  1142. "(excited)": 106,
  1143. "(sing)": 107,
  1144. "(cry)": 108,
  1145. "(heart)": 501,
  1146. "(teardrop)": 502,
  1147. "(star)": 503,
  1148. };
  1149. var script$6 = {
  1150. name: "Comment",
  1151. props: {
  1152. commentElem: commentElement,
  1153. },
  1154. data() {
  1155. return {
  1156. emoji: emoji,
  1157. };
  1158. },
  1159. computed: {
  1160. isStamp() {
  1161. if (this.commentElem.stampId !== null) {
  1162. return true;
  1163. }
  1164. else return false;
  1165. },
  1166. hasReply() {
  1167. return this.commentElem.hasReplies;
  1168. },
  1169. getStampUrl() {
  1170. return `https://s.pximg.net/common/images/stamp/generated-stamps/${commentElem.stampId}_s.jpg?20180605`;
  1171. },
  1172. replaceAll(str, beforeStr, afterStr) {
  1173. var reg = new RegExp(beforeStr, "g");
  1174. return str.replace(reg, afterStr);
  1175. },
  1176. getComment() {
  1177. const comment = this.commentElem.comment;
  1178. if (comment.includes(')')) {
  1179. let replaceComment = comment;
  1180. Object.keys(emoji).forEach(function(key) {
  1181. const regexp = new RegExp(key, 'g');
  1182. replaceComment = replaceComment.replace(regexp, `<span style="width: 14px; height: 14px; display: inline-block; background-image: url('https://s.pximg.net/common/images/emoji/${emoji[key]}.png'); background-size: contain;"></span>`);
  1183. });
  1184. return replaceComment;
  1185. } else {
  1186. return comment;
  1187. }
  1188. },
  1189. getName() {
  1190. return this.commentElem.userName;
  1191. },
  1192. getDate() {
  1193. return this.commentElem.commentDate;
  1194. },
  1195. commentInfo() {
  1196. return "hoge";
  1197. },
  1198. },
  1199. methods: {},
  1200. };
  1201. const __vue_script__$6 = script$6;
  1202. var __vue_render__$6 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"popup-comment"},[(_vm.isStamp)?_c('span',[_c('img',{attrs:{"src":'https://s.pximg.net/common/images/stamp/generated-stamps/' + _vm.commentElem.stampId+'_s.jpg?20180605'}})]):_c('span',{domProps:{"innerHTML":_vm._s(_vm.getComment)}}),_c('br'),_vm._v(" "),_c('span',{staticClass:"popup-comment-info"},[_vm._v(_vm._s(_vm.commentElem.userName)),_c('br'),_vm._v(_vm._s(_vm.commentElem.commentDate))])])};
  1203. var __vue_staticRenderFns__$6 = [];
  1204. const __vue_inject_styles__$6 = function (inject) {
  1205. if (!inject) return
  1206. inject("data-v-a8c38ba4_0", { source: ".popup-comment[data-v-a8c38ba4]{background:#eee;margin:5px;margin-right:15px}img[data-v-a8c38ba4]{width:48px;height:48px}.popup-ugoira-stamp[data-v-a8c38ba4]{width:48px;height:48px;background-repeat:no-repeat;background-size:cover;border-radius:2px}.popup-comment-info[data-v-a8c38ba4]{font-size:xx-small;text-align:left;color:#999}", map: undefined, media: undefined });
  1207. };
  1208. const __vue_scope_id__$6 = "data-v-a8c38ba4";
  1209. const __vue_module_identifier__$6 = undefined;
  1210. const __vue_is_functional_template__$6 = false;
  1211. var Comment = normalizeComponent_1(
  1212. { render: __vue_render__$6, staticRenderFns: __vue_staticRenderFns__$6 },
  1213. __vue_inject_styles__$6,
  1214. __vue_script__$6,
  1215. __vue_scope_id__$6,
  1216. __vue_is_functional_template__$6,
  1217. __vue_module_identifier__$6,
  1218. browser,
  1219. undefined
  1220. );
  1221. var script$7 = {
  1222. name: "CommentList",
  1223. components: {
  1224. Comment,
  1225. },
  1226. props: {
  1227. id: {
  1228. default: 'popup-commentlist',
  1229. type: String,
  1230. },
  1231. },
  1232. data() {
  1233. return {
  1234. screen: document.getElementById('popup-screen'),
  1235. comment: {
  1236. offset: 0,
  1237. max: 100,
  1238. hasNext: true,
  1239. },
  1240. };
  1241. },
  1242. computed: {
  1243. commentArray() {
  1244. const json = this.$store.state.commentJson;
  1245. return json.body.comments;
  1246. },
  1247. commentListStyle: function() {
  1248. const top = this.$store.state.caption.isVisible ? this.$store.state.caption.height : 0;
  1249. return {
  1250. whiteSpace: 'pre-wrap',
  1251. zIndex: 10000,
  1252. width: `120px`,
  1253. height: `${this.$store.state.screen.height + 10}px`,
  1254. display: 'inline-block',
  1255. overflowY: 'scroll',
  1256. backgroundColor: 'white',
  1257. border: '1px solid #000',
  1258. position: 'absolute',
  1259. top: `${top}px`,
  1260. left: `${this.$store.state.screen.width + 10}px`,
  1261. float: 'right',
  1262. };
  1263. },
  1264. offset: function() {
  1265. if (this.screen) {
  1266. const clientRect = this.screen.getBoundingClientRect();
  1267. return {
  1268. top: this.screen.style.top,
  1269. left: clientRect.left + this.screen.clientWidth + this.screen.clientWidth,
  1270. };
  1271. } else {
  1272. return { top: 0, left: 0 };
  1273. }
  1274. },
  1275. },
  1276. created: {},
  1277. updated: function() {
  1278. this.$nextTick(function() {
  1279. this.listHeight = this.$store.state.screen.height;
  1280. });
  1281. },
  1282. methods: {
  1283. infiniteHandler($state) {
  1284. },
  1285. },
  1286. };
  1287. const __vue_script__$7 = script$7;
  1288. var __vue_render__$7 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{style:(_vm.commentListStyle),attrs:{"id":_vm.id}},_vm._l((_vm.commentArray),function(elem){return _c('Comment',{attrs:{"comment-elem":elem}})}),1)};
  1289. var __vue_staticRenderFns__$7 = [];
  1290. const __vue_inject_styles__$7 = undefined;
  1291. const __vue_scope_id__$7 = "data-v-068ba0e9";
  1292. const __vue_module_identifier__$7 = undefined;
  1293. const __vue_is_functional_template__$7 = false;
  1294. var CommentList = normalizeComponent_1(
  1295. { render: __vue_render__$7, staticRenderFns: __vue_staticRenderFns__$7 },
  1296. __vue_inject_styles__$7,
  1297. __vue_script__$7,
  1298. __vue_scope_id__$7,
  1299. __vue_is_functional_template__$7,
  1300. __vue_module_identifier__$7,
  1301. undefined,
  1302. undefined
  1303. );
  1304. class PixivJson {
  1305. constructor(json) {
  1306. Object.assign(this, json);
  1307. }
  1308. }
  1309. class Util {
  1310. onloadExecute(store, url) {
  1311. function changeIllustPageLayout() {
  1312. let figures = document.getElementsByTagName('figure');
  1313. let figcaptions = document.getElementsByTagName('figcaption');
  1314. if (figures.length === figcaptions.length) {
  1315. for (let i = 0; i < figures.length; i++) {
  1316. figures[i].parentNode.insertBefore(figcaptions[i], figures[i]);
  1317. }
  1318. }
  1319. }
  1320. function changeAutherPageLayout() {
  1321. const h2Elems = document.getElementsByTagName('h2');
  1322. if (typeof h2Elems !== 'undefined') {
  1323. for (const h2elem of h2Elems) {
  1324. if (h2elem.innerText.startsWith('イラスト') || h2elem.innerText.startsWith('作品')) {
  1325. const illustElem = h2elem.parentElement.parentElement;
  1326. const header = document.getElementsByTagName('header')[0];
  1327. const parent = header.parentNode;
  1328. parent.insertBefore(illustElem, header.nextSibling);
  1329. break;
  1330. }
  1331. }
  1332. }
  1333. }
  1334. if (store.state.enable.modifyIllustPage && ~url.indexOf('member_illust.php?mode=medium')) {
  1335. changeIllustPageLayout();
  1336. } else if (store.state.enable.modifyAutherPage) {
  1337. if (~url.indexOf('member.php?') || ~url.indexOf('member_illust.php?') || ~url.indexOf('bookmark.php?'))
  1338. changeAutherPageLayout();
  1339. }
  1340. }
  1341. async getPixivJson(illustId) {
  1342. await fetch(`https://www.pixiv.net/ajax/illust/${illustId}`,
  1343. {
  1344. method: 'GET',
  1345. mode: 'cors',
  1346. keepalive: true,
  1347. },
  1348. ).then(function (response) {
  1349. if (response.ok) {
  1350. return response.json();
  1351. }
  1352. }).then(async function (json) {
  1353. return new PixivJson(json);
  1354. });
  1355. }
  1356. async getUgoiraJson(illustId) {
  1357. const url = `https://www.pixiv.net/ajax/illust/${illustId}/ugoira_meta`;
  1358. await fetch(url,
  1359. {
  1360. method: 'GET',
  1361. mode: 'cors',
  1362. keepalive: true,
  1363. }).then(function (response) {
  1364. if (response.ok) {
  1365. return response.json();
  1366. }
  1367. }).then((json) => {
  1368. return new PixivJson(json)
  1369. });
  1370. }
  1371. async loadGmData(store) {
  1372. await GM.getValue("pixiv_viewutil_setting").then(jsonString => {
  1373. if (jsonString !== undefined) {
  1374. const jsonData = JSON.parse(jsonString);
  1375. store.commit('setAutherPageBool', (jsonData.changeIllustPageLayout == null) ? true : jsonData.changeIllustPageLayout);
  1376. store.commit('setAutherPageBool', (jsonData.changeMemberPageLayout == null) ? true : jsonData.changeMemberPageLayout);
  1377. store.commit('setPopupBool', (jsonData.usePopup == null) ? true : jsonData.usePopup);
  1378. store.commit('setPopupScale', (jsonData.popupScale == null) ? 0.7 : jsonData.popupScale);
  1379. } else {
  1380. store.commit('setAutherPageBool', true);
  1381. store.commit('setAutherPageBool', true);
  1382. store.commit('setPopupBool', true);
  1383. store.commit('setPopupScale', 0.7);
  1384. }
  1385. });
  1386. }
  1387. saveGmData(obj) {
  1388. const jsonObj = JSON.stringify(obj);
  1389. console.log(JSON.stringify(obj));
  1390. GM.setValue("pixiv_viewutil_setting", jsonObj);
  1391. }
  1392. }
  1393. var script$8 = {
  1394. name: 'MainContainer',
  1395. components: {
  1396. Caption,
  1397. Illust,
  1398. Manga,
  1399. Ugoira,
  1400. CommentList,
  1401. },
  1402. data() {
  1403. return {
  1404. illustId: null,
  1405. }
  1406. },
  1407. beforeCreate() {
  1408. },
  1409. computed: {
  1410. myData: function () {
  1411. const json = this.$store.state.pixivJson;
  1412. return json.body.illustTitle;
  1413. },
  1414. isVisible: function () {
  1415. return this.$store.state.screen.isVisible;
  1416. },
  1417. screenLoaded: function () {
  1418. return this.$store.state.screen.isLoaded;
  1419. },
  1420. visibleCaption: function () {
  1421. return this.$store.state.caption.isVisible;
  1422. },
  1423. visibleCommentList: function () {
  1424. return this.$store.state.comment.isVisible;
  1425. },
  1426. isIllust: function () {
  1427. return this.$store.state.pixivJson.body.illustType === 0 && this.$store.state.pixivJson.body.pageCount < 2
  1428. },
  1429. isManga: function () {
  1430. return this.$store.state.pixivJson.body.illustType === 1 || (this.$store.state.pixivJson.body.pageCount && this.$store.state.pixivJson.body.pageCount > 1);
  1431. },
  1432. isUgoira: function () {
  1433. return this.$store.state.pixivJson.body.illustType === 2
  1434. },
  1435. containerStyle: function () {
  1436. const scroll = (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop;
  1437. return {
  1438. zIndex: 10000,
  1439. position: 'relative',
  1440. display: 'block',
  1441. top: `${scroll + window.innerHeight / 2}px`,
  1442. left: `${window.innerWidth / 2}px`,
  1443. transform: 'translate(-50%,-50%)',
  1444. width: `auto`,
  1445. height: `auto`,
  1446. };
  1447. },
  1448. },
  1449. mounted() {
  1450. const store = this.$store;
  1451. const el = this.$el;
  1452. document.querySelectorAll('a[href^="/artworks/"],a[href*="member_illust.php?mode=medium&illust_id="]').forEach(link => {
  1453. link.addEventListener('mouseenter', function () {
  1454. const clickElem = this.querySelector('.non-trim-thumb') || this;
  1455. clickElem.setAttribute('onclick', 'console.log();return false;');
  1456. if (clickElem.classList.contains('ugoku-illust')) {
  1457. store.commit('isUgoira', true);
  1458. } else {
  1459. store.commit('isUgoira', false);
  1460. }
  1461. const url = this.getAttribute('href');
  1462. let preLoadID = null;
  1463. if (url.startsWith("/artworks/")) {
  1464. const matches = url.match(/\/artworks\/([0-9]+)/);
  1465. preLoadID = Number(matches[1]);
  1466. this.illustId = preLoadID;
  1467. store.commit('setIllustID', preLoadID);
  1468. clickElem.addEventListener('click', function () {
  1469. el.style.top = `${window.pageYOffset + window.innerHeight / 2}px`,
  1470. el.style.left = `${window.innerWidth / 2}px`,
  1471. store.commit('fetchScreen');
  1472. });
  1473. } else {
  1474. const matches = url.match(/(.)+illust_id=([0-9]+)(&.+)?/);
  1475. preLoadID = Number(matches[2]);
  1476. this.illustId = preLoadID;
  1477. store.commit('setIllustID', preLoadID);
  1478. clickElem.addEventListener('click', function () {
  1479. el.style.top = `${window.pageYOffset + window.innerHeight / 2}px`,
  1480. el.style.left = `${window.innerWidth / 2}px`,
  1481. store.commit('fetchScreen');
  1482. });
  1483. }
  1484. });
  1485. });
  1486. },
  1487. destroyed: function () {
  1488. },
  1489. methods: {
  1490. toggleComment: function () {
  1491. this.$store.commit('toggleComment');
  1492. },
  1493. toggleCaption: function () {
  1494. this.$store.commit('toggleCaption');
  1495. },
  1496. hide: function () {
  1497. this.$store.commit('hide');
  1498. },
  1499. },
  1500. };
  1501. const __vue_script__$8 = script$8;
  1502. var __vue_render__$8 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.isVisible),expression:"isVisible"}],style:(_vm.containerStyle),attrs:{"id":"popup-outer-container"}},[(_vm.visibleCaption)?_c('Caption',{directives:[{name:"show",rawName:"v-show",value:(_vm.screenLoaded),expression:"screenLoaded"}]}):_vm._e(),_vm._v(" "),(_vm.isIllust)?_c('Illust'):(_vm.isUgoira)?_c('Ugoira',{attrs:{"visible":_vm.isVisible}}):_c('Manga'),_vm._v(" "),(_vm.visibleCommentList)?_c('CommentList',{directives:[{name:"show",rawName:"v-show",value:(_vm.screenLoaded),expression:"screenLoaded"}]}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"togglebar togglebar-horizontal is-clickable",on:{"click":_vm.toggleCaption}},[(_vm.visibleCaption)?_c('i',{staticClass:"arrow down is-clickable"}):_vm._e(),_vm._v(" "),(! _vm.visibleCaption)?_c('i',{staticClass:"arrow up is-clickable"}):_vm._e()]),_vm._v(" "),_c('div',{staticClass:"togglebar togglebar-vertical is-clickable",on:{"click":_vm.toggleComment}},[(_vm.visibleCommentList)?_c('i',{staticClass:"arrow left is-clickable"}):_vm._e(),_vm._v(" "),(! _vm.visibleCommentList)?_c('i',{staticClass:"arrow right is-clickable"}):_vm._e()])],1)};
  1503. var __vue_staticRenderFns__$8 = [];
  1504. const __vue_inject_styles__$8 = function (inject) {
  1505. if (!inject) return
  1506. inject("data-v-70cd807a_0", { source: ".arrow[data-v-70cd807a]{position:absolute;z-index:10002;border:solid #c1c1c1;border-width:0 3px 3px 0;display:inline-block;padding:3px;top:50%;left:50%;cursor:pointer}.right[data-v-70cd807a]{left:-1px;transform:rotate(-45deg);-webkit-transform:rotate(-45deg)}.left[data-v-70cd807a]{left:1px;transform:rotate(135deg);-webkit-transform:rotate(135deg)}.up[data-v-70cd807a]{transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}.down[data-v-70cd807a]{top:0;transform:rotate(45deg);-webkit-transform:rotate(45deg)}.togglebar[data-v-70cd807a]{position:absolute;border-radius:10px 10px 10px 10px;border:1px solid #d4d4d4;cursor:pointer;z-index:10001;background-color:#f8f8f8}.togglebar-horizontal[data-v-70cd807a]{width:100px;height:10px;left:50%;transform:translate(-50%,0)}.togglebar-vertical[data-v-70cd807a]{width:10px;height:100px;top:50%;right:0;transform:translate(0,-50%)}", map: undefined, media: undefined });
  1507. };
  1508. const __vue_scope_id__$8 = "data-v-70cd807a";
  1509. const __vue_module_identifier__$8 = undefined;
  1510. const __vue_is_functional_template__$8 = false;
  1511. var App = normalizeComponent_1(
  1512. { render: __vue_render__$8, staticRenderFns: __vue_staticRenderFns__$8 },
  1513. __vue_inject_styles__$8,
  1514. __vue_script__$8,
  1515. __vue_scope_id__$8,
  1516. __vue_is_functional_template__$8,
  1517. __vue_module_identifier__$8,
  1518. browser,
  1519. undefined
  1520. );
  1521. var script$9 = {
  1522. name: "FontAwesome",
  1523. props: {
  1524. icon: {
  1525. default: 'cog',
  1526. type: String,
  1527. },
  1528. },
  1529. };
  1530. const __vue_script__$9 = script$9;
  1531. var __vue_render__$9 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.icon === 'cog')?_c('svg',{staticClass:"svg-inline--fa fa-cog fa-w-16",attrs:{"aria-hidden":"true","data-prefix":"fas","data-icon":"cog","role":"img","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 512 512"}},[_c('path',{attrs:{"fill":"#becad8","d":"M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z"}})]):_vm._e()};
  1532. var __vue_staticRenderFns__$9 = [];
  1533. const __vue_inject_styles__$9 = undefined;
  1534. const __vue_scope_id__$9 = undefined;
  1535. const __vue_module_identifier__$9 = undefined;
  1536. const __vue_is_functional_template__$9 = false;
  1537. var FontAwesome = normalizeComponent_1(
  1538. { render: __vue_render__$9, staticRenderFns: __vue_staticRenderFns__$9 },
  1539. __vue_inject_styles__$9,
  1540. __vue_script__$9,
  1541. __vue_scope_id__$9,
  1542. __vue_is_functional_template__$9,
  1543. __vue_module_identifier__$9,
  1544. undefined,
  1545. undefined
  1546. );
  1547. var script$a = {
  1548. name: 'Modal',
  1549. data() {
  1550. return {}
  1551. },
  1552. computed: {
  1553. changeIllustPage: {
  1554. get() {
  1555. return this.$store.state.enable.modifyIllustPage
  1556. },
  1557. set(value) {
  1558. this.$store.commit('setIllustPageBool', value);
  1559. }
  1560. },
  1561. changeAutherPage: {
  1562. get() {
  1563. return this.$store.state.enable.modifyAutherPage
  1564. },
  1565. set(value) {
  1566. this.$store.commit('setAutherPageBool', value);
  1567. }
  1568. },
  1569. enablePopup: {
  1570. get() {
  1571. return this.$store.state.enable.pupupScreen
  1572. },
  1573. set(value) {
  1574. this.$store.commit('setPopupBool', value);
  1575. }
  1576. },
  1577. setSize:{
  1578. get() {
  1579. return this.$store.state.screen.scale
  1580. },
  1581. set(value) {
  1582. this.$store.commit('setPopupScale', value);
  1583. }
  1584. }
  1585. }
  1586. };
  1587. const __vue_script__$a = script$a;
  1588. var __vue_render__$a = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"modal"}},[_c('div',{staticClass:"modal-mask"},[_c('div',{staticClass:"modal-wrapper ",on:{"click":function($event){if($event.target !== $event.currentTarget){ return null; }return _vm.$emit('close')}}},[_c('div',{staticClass:"modal-container"},[_c('div',{staticClass:"modal-header"},[_c('h1',[_vm._v("Pixiv View Util")])]),_vm._v(" "),_c('div',{staticClass:"modal-body"},[_c('label',{staticClass:"control control-checkbox"},[_vm._v("\n Modify the illust page's layout\n "),_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.changeIllustPage),expression:"changeIllustPage"}],attrs:{"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.changeIllustPage)?_vm._i(_vm.changeIllustPage,null)>-1:(_vm.changeIllustPage)},on:{"change":function($event){var $$a=_vm.changeIllustPage,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.changeIllustPage=$$a.concat([$$v]));}else{$$i>-1&&(_vm.changeIllustPage=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{_vm.changeIllustPage=$$c;}}}}),_vm._v(" "),_c('div',{staticClass:"control_indicator"})]),_vm._v(" "),_c('label',{staticClass:"control control-checkbox"},[_vm._v("\n Modify the auhor page's layout\n "),_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.changeAutherPage),expression:"changeAutherPage"}],attrs:{"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.changeAutherPage)?_vm._i(_vm.changeAutherPage,null)>-1:(_vm.changeAutherPage)},on:{"change":function($event){var $$a=_vm.changeAutherPage,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.changeAutherPage=$$a.concat([$$v]));}else{$$i>-1&&(_vm.changeAutherPage=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{_vm.changeAutherPage=$$c;}}}}),_vm._v(" "),_c('div',{staticClass:"control_indicator"})]),_vm._v(" "),_c('label',{staticClass:"control control-checkbox"},[_vm._v("\n Use popup function\n "),_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.enablePopup),expression:"enablePopup"}],attrs:{"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.enablePopup)?_vm._i(_vm.enablePopup,null)>-1:(_vm.enablePopup)},on:{"change":function($event){var $$a=_vm.enablePopup,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.enablePopup=$$a.concat([$$v]));}else{$$i>-1&&(_vm.enablePopup=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{_vm.enablePopup=$$c;}}}}),_vm._v(" "),_c('div',{staticClass:"control_indicator"})]),_vm._v(" "),_c('h2',[_vm._v("Popup size (min <-> max)")]),_vm._v(" "),_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.setSize),expression:"setSize"}],attrs:{"type":"range","min":"0.3","max":"1.2","step":"0.1","id":"pixiv-set-scale"},domProps:{"value":(_vm.setSize)},on:{"__r":function($event){_vm.setSize=$event.target.value;}}}),_vm._v(" "),_c('div',{staticClass:"modal-footer"},[_c('button',{staticClass:"myButton",on:{"click":function($event){return _vm.$emit('close')}}},[_vm._v("\n OK\n ")])])])])])])])};
  1589. var __vue_staticRenderFns__$a = [];
  1590. const __vue_inject_styles__$a = function (inject) {
  1591. if (!inject) return
  1592. inject("data-v-1193b908_0", { source: ".modal-mask[data-v-1193b908]{position:fixed;z-index:9998;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.5);display:table;transition:opacity .3s ease}.modal-wrapper[data-v-1193b908]{display:table-cell;vertical-align:middle}.modal-container[data-v-1193b908]{width:300px;margin:0 auto;padding:20px 30px;background-color:#fff;border-radius:2px;box-shadow:0 2px 8px rgba(0,0,0,.33);transition:all .3s ease;font-family:Helvetica,Arial,sans-serif}.modal-header h3[data-v-1193b908]{margin-top:0;color:#42b983}.modal-body[data-v-1193b908]{margin:20px 0}.modal-default-button[data-v-1193b908]{float:right}.modal-enter[data-v-1193b908]{opacity:0}.modal-leave-active[data-v-1193b908]{opacity:0}.modal-enter .modal-container[data-v-1193b908],.modal-leave-active .modal-container[data-v-1193b908]{-webkit-transform:scale(1.1);transform:scale(1.1)}.myButton[data-v-1193b908]{background:-webkit-gradient(linear,left top,left bottom,color-stop(.05,#7892c2),color-stop(1,#476e9e));background:-moz-linear-gradient(top,#7892c2 5%,#476e9e 100%);background:-webkit-linear-gradient(top,#7892c2 5%,#476e9e 100%);background:-o-linear-gradient(top,#7892c2 5%,#476e9e 100%);background:-ms-linear-gradient(top,#7892c2 5%,#476e9e 100%);background:linear-gradient(to bottom,#7892c2 5%,#476e9e 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7892c2', endColorstr='#476e9e', GradientType=0);background-color:#7892c2;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border:1px solid #4e6096;display:inline-block;cursor:pointer;color:#fff;font-family:Arial;font-size:16px;padding:10px 20px;text-decoration:none}.myButton[data-v-1193b908]:hover{background:-webkit-gradient(linear,left top,left bottom,color-stop(.05,#476e9e),color-stop(1,#7892c2));background:-moz-linear-gradient(top,#476e9e 5%,#7892c2 100%);background:-webkit-linear-gradient(top,#476e9e 5%,#7892c2 100%);background:-o-linear-gradient(top,#476e9e 5%,#7892c2 100%);background:-ms-linear-gradient(top,#476e9e 5%,#7892c2 100%);background:linear-gradient(to bottom,#476e9e 5%,#7892c2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#476e9e', endColorstr='#7892c2', GradientType=0);background-color:#476e9e}.myButton[data-v-1193b908]:active{position:relative;top:1px}input[type=range][data-v-1193b908]{height:25px;-webkit-appearance:none;margin:10px 0;width:100%}input[type=range][data-v-1193b908]:focus{outline:0}input[type=range][data-v-1193b908]::-webkit-slider-runnable-track{width:100%;height:5px;cursor:pointer;animate:.2s;box-shadow:0 0 0 #000;background:#c3d7e3;border-radius:1px;border:0 solid #000}input[type=range][data-v-1193b908]::-webkit-slider-thumb{box-shadow:0 0 0 #000;border:1px solid #4e6096;height:18px;width:18px;border-radius:25px;background:#597bab;cursor:pointer;-webkit-appearance:none;margin-top:-7px}input[type=range][data-v-1193b908]:focus::-webkit-slider-runnable-track{background:#c3d7e3}input[type=range][data-v-1193b908]::-moz-range-track{width:100%;height:5px;cursor:pointer;animate:.2s;box-shadow:0 0 0 #000;background:#c3d7e3;border-radius:1px;border:0 solid #000}input[type=range][data-v-1193b908]::-moz-range-thumb{box-shadow:0 0 0 #000;border:1px solid #2497e3;height:18px;width:18px;border-radius:25px;background:#5c82ff;cursor:pointer}input[type=range][data-v-1193b908]::-ms-track{width:100%;height:5px;cursor:pointer;animate:.2s;background:0 0;border-color:transparent;color:transparent}input[type=range][data-v-1193b908]::-ms-fill-lower{background:#c3d7e3;border:0 solid #000;border-radius:2px;box-shadow:0 0 0 #000}input[type=range][data-v-1193b908]::-ms-fill-upper{background:#c3d7e3;border:0 solid #000;border-radius:2px;box-shadow:0 0 0 #000}input[type=range][data-v-1193b908]::-ms-thumb{margin-top:1px;box-shadow:0 0 0 #000;border:1px solid #2497e3;height:18px;width:18px;border-radius:25px;background:#5c82ff;cursor:pointer}input[type=range][data-v-1193b908]:focus::-ms-fill-lower{background:#c3d7e3}input[type=range][data-v-1193b908]:focus::-ms-fill-upper{background:#c3d7e3}.control[data-v-1193b908]{font-family:arial;display:block;position:relative;padding-left:30px;margin-bottom:5px;padding-top:2px;cursor:pointer;font-size:14px}.control input[data-v-1193b908]{position:absolute;z-index:-1;opacity:0}.control_indicator[data-v-1193b908]{position:absolute;top:2px;left:0;height:20px;width:20px;background:#e6e6e6;border:0 solid #000}.control-radio .control_indicator[data-v-1193b908]{border-radius:undefined%}.control input:focus~.control_indicator[data-v-1193b908],.control:hover input~.control_indicator[data-v-1193b908]{background:#ccc}.control input:checked~.control_indicator[data-v-1193b908]{background:#597caf}.control input:checked:focus~.control_indicator[data-v-1193b908],.control:hover input:not([disabled]):checked~.control_indicator[data-v-1193b908]{background:#0e6647d}.control input:disabled~.control_indicator[data-v-1193b908]{background:#e6e6e6;opacity:.6;pointer-events:none}.control_indicator[data-v-1193b908]:after{box-sizing:unset;content:'';position:absolute;display:none}.control input:checked~.control_indicator[data-v-1193b908]:after{display:block}.control-checkbox .control_indicator[data-v-1193b908]:after{left:8px;top:4px;width:3px;height:8px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}.control-checkbox input:disabled~.control_indicator[data-v-1193b908]:after{border-color:#7b7b7b}", map: undefined, media: undefined });
  1593. };
  1594. const __vue_scope_id__$a = "data-v-1193b908";
  1595. const __vue_module_identifier__$a = undefined;
  1596. const __vue_is_functional_template__$a = false;
  1597. var modal = normalizeComponent_1(
  1598. { render: __vue_render__$a, staticRenderFns: __vue_staticRenderFns__$a },
  1599. __vue_inject_styles__$a,
  1600. __vue_script__$a,
  1601. __vue_scope_id__$a,
  1602. __vue_is_functional_template__$a,
  1603. __vue_module_identifier__$a,
  1604. browser,
  1605. undefined
  1606. );
  1607. var script$b = {
  1608. name: "Cog",
  1609. components: {
  1610. FontAwesome,
  1611. modal
  1612. },
  1613. data() {
  1614. return {
  1615. showModal: false
  1616. }
  1617. },
  1618. methods: {
  1619. toggleModal() {
  1620. if (this.showModal) {
  1621. this.showModal = false;
  1622. this.save();
  1623. } else {
  1624. this.showModal = true;
  1625. }
  1626. },
  1627. save(){
  1628. const util=new Util();
  1629. const obj = {
  1630. changeIllustPageLayout: this.$store.state.enable.modifyIllustPage,
  1631. changeMemberPageLayout: this.$store.state.enable.modifyAutherPage,
  1632. openComment: true,
  1633. usePopup: this.$store.state.enable.pupupScreen,
  1634. popupCaption:true,
  1635. popupComment:true,
  1636. popupScale: this.$store.state.screen.scale
  1637. };
  1638. util.saveGmData(obj);
  1639. }
  1640. }
  1641. };
  1642. const __vue_script__$b = script$b;
  1643. var __vue_render__$b = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{"id":"popup-cog"}},[_c('div',{staticClass:"icon",on:{"click":_vm.toggleModal}},[_c('FontAwesome',{staticStyle:{"margin":"auto"},attrs:{"icon":'cog'}})],1),_vm._v(" "),(_vm.showModal)?_c('modal',{on:{"close":_vm.toggleModal}}):_vm._e()],1)};
  1644. var __vue_staticRenderFns__$b = [];
  1645. const __vue_inject_styles__$b = function (inject) {
  1646. if (!inject) return
  1647. inject("data-v-1eb98629_0", { source: ".icon[data-v-1eb98629]{width:24px;height:24px;position:relative;cursor:pointer}", map: undefined, media: undefined });
  1648. };
  1649. const __vue_scope_id__$b = "data-v-1eb98629";
  1650. const __vue_module_identifier__$b = undefined;
  1651. const __vue_is_functional_template__$b = false;
  1652. var Cog = normalizeComponent_1(
  1653. { render: __vue_render__$b, staticRenderFns: __vue_staticRenderFns__$b },
  1654. __vue_inject_styles__$b,
  1655. __vue_script__$b,
  1656. __vue_scope_id__$b,
  1657. __vue_is_functional_template__$b,
  1658. __vue_module_identifier__$b,
  1659. browser,
  1660. undefined
  1661. );
  1662. Vue.use(Vuex);
  1663. const artworkType = {
  1664. illust: Symbol('illust'),
  1665. manga: Symbol('manga'),
  1666. ugoira: Symbol('ugoira'),
  1667. };
  1668. const illustData = {
  1669. imgUrl: '',
  1670. };
  1671. const mangaData = {
  1672. page: 0,
  1673. imgUrl: [],
  1674. };
  1675. const state = {
  1676. illustID: 0,
  1677. isUgoira: false,
  1678. enable: {
  1679. modifyIllustPage: true,
  1680. modifyAutherPage: true,
  1681. pupupScreen: true,
  1682. },
  1683. screen: {
  1684. id: 'popup-outer-container',
  1685. elem: { clientWidth: 600, clientHeight: 600 },
  1686. isVisible: false,
  1687. isLoaded: false,
  1688. top: '50%',
  1689. left: '50%',
  1690. scale: 0.8,
  1691. width: 600,
  1692. height: 600,
  1693. transform: 'translate(-50%,-70%)',
  1694. dragging: false,
  1695. },
  1696. caption: {
  1697. isVisible: true,
  1698. height: 100,
  1699. },
  1700. comment: {
  1701. isVisible: true,
  1702. },
  1703. preload: {
  1704. pixivJson: basicResponse,
  1705. commentJson: commentResponse,
  1706. ugoiraJson: ugoiraResponse,
  1707. artworktype: artworkType.illust,
  1708. illustData: illustData,
  1709. mangaData: mangaData,
  1710. },
  1711. pixivJson: basicResponse,
  1712. commentJson: commentResponse,
  1713. ugoiraJson: ugoiraResponse,
  1714. artworktype: artworkType.illust,
  1715. illustData: illustData,
  1716. mangaData: mangaData,
  1717. };
  1718. const actions = {};
  1719. const getters = {};
  1720. const mutations = {
  1721. async setIllustID(state, id) {
  1722. state.illustID = id;
  1723. state.preload.pixivJson = await fetch(`https://www.pixiv.net/ajax/illust/${id}`,
  1724. {
  1725. method: 'GET',
  1726. mode: 'cors',
  1727. keepalive: true,
  1728. },
  1729. ).then(function(response) {
  1730. if (response.ok) {
  1731. return response.json();
  1732. }
  1733. }).then(json => {
  1734. return new PixivJson$1(json);
  1735. });
  1736. if (state.comment.isVisible) {
  1737. const url = `https://www.pixiv.net/ajax/illusts/comments/roots?illust_id=${id}&offset=${0}&limit=${100}`;
  1738. state.preload.commentJson = await fetch(url,
  1739. {
  1740. method: 'GET',
  1741. mode: 'cors',
  1742. keepalive: true,
  1743. }).then(function(response) {
  1744. if (response.ok) {
  1745. return response.json();
  1746. }
  1747. }).then((json) => {
  1748. return new PixivJson$1(json);
  1749. });
  1750. }
  1751. if (state.isUgoira) {
  1752. const url = `https://www.pixiv.net/ajax/illust/${id}/ugoira_meta`;
  1753. state.preload.ugoiraJson = await fetch(url,
  1754. {
  1755. method: 'GET',
  1756. mode: 'cors',
  1757. keepalive: true,
  1758. }).then(function(response) {
  1759. if (response.ok) {
  1760. return response.json();
  1761. }
  1762. }).then((json) => {
  1763. return new PixivJson$1(json);
  1764. });
  1765. }
  1766. },
  1767. setScreen(state, elem) {
  1768. state.screen.elem = elem;
  1769. }
  1770. ,
  1771. screenTop() {
  1772. return state.screen.top;
  1773. }
  1774. ,
  1775. screenHeight(state, sHeight) {
  1776. state.screen.height = sHeight;
  1777. state.comment.height = sHeight + 10;
  1778. },
  1779. screenWidth(state, sWidth) {
  1780. state.screen.width = sWidth;
  1781. state.caption.width = sWidth + 10;
  1782. },
  1783. captionHeight(state, height) {
  1784. state.caption.height = height;
  1785. },
  1786. screenLoaded(state) {
  1787. state.screen.isLoaded = true;
  1788. },
  1789. isUgoira(state, bool) {
  1790. state.isUgoira = bool;
  1791. },
  1792. fetchScreen(state) {
  1793. state.pixivJson = JSON.parse(JSON.stringify(state.preload.pixivJson));
  1794. state.commentJson = JSON.parse(JSON.stringify(state.preload.commentJson));
  1795. state.ugoiraJson = JSON.parse(JSON.stringify(state.preload.ugoiraJson));
  1796. state.artworktype = state.preload.artworktype;
  1797. state.screen.isVisible = true;
  1798. state.screen.left = '50%';
  1799. state.screen.top = '50%';
  1800. }
  1801. ,
  1802. showScreen(state) {
  1803. state.screen.isVisible = true;
  1804. state.screen.left = '50%';
  1805. state.screen.top = '50%';
  1806. }
  1807. ,
  1808. hide(state) {
  1809. state.screen.isVisible = false;
  1810. state.screen.isLoaded = false;
  1811. }
  1812. ,
  1813. setIllustPageBool(state, value) {
  1814. state.enable.modifyIllustPage = value;
  1815. },
  1816. setAutherPageBool(state, value) {
  1817. state.enable.modifyAutherPage = value;
  1818. },
  1819. setPopupBool(state, value) {
  1820. state.enable.pupupScreen = value;
  1821. },
  1822. setPopupScale(state, value) {
  1823. state.screen.scale = value;
  1824. },
  1825. toggleCaption(state) {
  1826. state.caption.isVisible = !state.caption.isVisible;
  1827. },
  1828. toggleComment(state) {
  1829. state.comment.isVisible = !state.comment.isVisible;
  1830. },
  1831. }
  1832. ;
  1833. const store = new Vuex.Store({
  1834. state,
  1835. getters,
  1836. actions,
  1837. mutations,
  1838. });
  1839. class PixivJson$1 {
  1840. constructor(json) {
  1841. Object.assign(this, json);
  1842. }
  1843. }
  1844. const util = new Util();
  1845. util.loadGmData(store);
  1846. Vue.config.productionTip = true;
  1847. Vue.directive('draggable', {
  1848. store: store,
  1849. bind: function(el) {
  1850. el.style.position = 'absolute';
  1851. let startX, startY, initialMouseX, initialMouseY;
  1852. function mousemove(e) {
  1853. let dx = e.clientX - initialMouseX;
  1854. var dy = e.clientY - initialMouseY;
  1855. el.style.top = startY + dy + 'px';
  1856. el.style.left = startX + dx + 'px';
  1857. if (Math.abs(dx) > 1 || Math.abs(dy) > 1) {
  1858. store.state.screen.dragging = true;
  1859. }
  1860. return false;
  1861. }
  1862. function mouseup(e) {
  1863. document.removeEventListener('mousemove', mousemove);
  1864. document.removeEventListener('mouseup', mouseup);
  1865. if (store.state.screen.dragging || e.target.classList.contains('is-clickable')) {
  1866. store.state.screen.isVisible = true;
  1867. } else {
  1868. store.state.screen.isVisible = false;
  1869. }
  1870. store.state.screen.dragging = false;
  1871. return false;
  1872. }
  1873. el.addEventListener('mousedown', function(e) {
  1874. startX = el.offsetLeft;
  1875. startY = el.offsetTop;
  1876. initialMouseX = e.clientX;
  1877. initialMouseY = e.clientY;
  1878. store.state.screen.dragging = false;
  1879. document.addEventListener('mousemove', mousemove);
  1880. document.addEventListener('mouseup', mouseup);
  1881. return false;
  1882. });
  1883. },
  1884. });
  1885. window.onload = () => {
  1886. util.onloadExecute(store, document.URL);
  1887. const links = document.getElementsByTagName('a');
  1888. for (const link of links) {
  1889. link.addEventListener('click', () => {
  1890. util.onloadExecute(store, document.URL);
  1891. });
  1892. }
  1893. const cogID = 'popup-cog';
  1894. const notification = document.getElementsByClassName('notifications');
  1895. if (notification !== null && notification.length > 0 && document.getElementById('cogID') === null) {
  1896. const _li = document.createElement('li');
  1897. const div = document.createElement('div');
  1898. div.id = cogID;
  1899. notification[0].appendChild(_li);
  1900. _li.appendChild(div);
  1901. new Vue({
  1902. store: store,
  1903. el: `#popup-cog`,
  1904. components: {
  1905. Cog,
  1906. modal,
  1907. },
  1908. template: '<Cog/>',
  1909. });
  1910. }
  1911. const outerContainerID = 'popup-outer-container';
  1912. if (document.getElementById(outerContainerID) === null) {
  1913. const container = document.createElement('div');
  1914. container.id = outerContainerID;
  1915. document.body.appendChild(container);
  1916. new Vue({
  1917. store: store,
  1918. el: `#popup-outer-container`,
  1919. components: {
  1920. App,
  1921. },
  1922. template: '<App v-draggable/>',
  1923. });
  1924. }
  1925. };
  1926.  
  1927. }(Vue, Vuex));

QingJ © 2025

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