/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 307:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ A: () => (/* binding */ Store)
/* harmony export */ });
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* 存储
*/
var Store = /*#__PURE__*/function () {
function Store() {
_classCallCheck(this, Store);
}
return _createClass(Store, null, [{
key: "get",
value:
/**
* 获取
* @param key 键
*/
function get(key) {
return GM_getValue(key);
}
/**
* 设置
* @param key 键
* @param value 值
*/
}, {
key: "set",
value: function set(key, value) {
GM_setValue(key, value);
}
}]);
}();
/***/ }),
/***/ 481:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
A: () => (/* binding */ Options)
});
// EXTERNAL MODULE: ./utils/src/gm/Store.ts
var Store = __webpack_require__(307);
;// ./utils/src/gm/MenuCmd.ts
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* 选项菜单
*/
var MenuCmd = /*#__PURE__*/function () {
function MenuCmd() {
_classCallCheck(this, MenuCmd);
}
return _createClass(MenuCmd, null, [{
key: "register",
value:
/**
* 注册
* @param name 名称
* @param fn 点击菜单时执行的函数
*/
function register(name, fn) {
return GM_registerMenuCommand(name, fn);
}
/**
* 注销
* @param menuCmdId 注册时返回的 ID
*/
}, {
key: "unregister",
value: function unregister(menuCmdId) {
GM_unregisterMenuCommand(menuCmdId);
}
}]);
}();
;// ./utils/src/CommonOptions.ts
function CommonOptions_typeof(o) { "@babel/helpers - typeof"; return CommonOptions_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, CommonOptions_typeof(o); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function CommonOptions_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function CommonOptions_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, CommonOptions_toPropertyKey(o.key), o); } }
function CommonOptions_createClass(e, r, t) { return r && CommonOptions_defineProperties(e.prototype, r), t && CommonOptions_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function CommonOptions_toPropertyKey(t) { var i = CommonOptions_toPrimitive(t, "string"); return "symbol" == CommonOptions_typeof(i) ? i : i + ""; }
function CommonOptions_toPrimitive(t, r) { if ("object" != CommonOptions_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != CommonOptions_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* 选项菜单
*/
var CommonOptions = /*#__PURE__*/function () {
function CommonOptions() {
CommonOptions_classCallCheck(this, CommonOptions);
}
return CommonOptions_createClass(CommonOptions, null, [{
key: "registerBoolOption",
value:
/**
* 注册 bool 类型的选项
*
* @param option 选项
*/
function registerBoolOption(option) {
var _this = this;
var val = option.value,
valIsBool = typeof val === 'boolean';
if (!valIsBool) {
return;
}
// 注册选项和选项点击事件
var currentMenuCmdId = MenuCmd.register((val ? '✅ ' : '🔲 ') + option.label, function () {
// 点击后取反
option.value = !option.value;
Store/* default */.A.set(option.name, JSON.stringify(option));
// 重新注册
MenuCmd.unregister(currentMenuCmdId);
_this.registerBoolOption(option);
// 刷新页面
window.location.reload();
});
// 保存选项 ID
option.menuCmdId = currentMenuCmdId;
Store/* default */.A.set(option.name, JSON.stringify(option));
}
/**
* 注册所有选项
*
* @param options 选项
* @param moreOptionsUrl 更多设置页面 URL
*/
}, {
key: "registerAll",
value: function registerAll(options, moreOptionsUrl) {
// 注册“更多设置”选项,点击后打开新页面
MenuCmd.register('更多设置', function () {
window.open(moreOptionsUrl, '_blank');
});
var _iterator = _createForOfIteratorHelper(options),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var option = _step.value;
// TODO 【调试】不保留选项的值,每次都从 Store 中获取
// Store.set(option.name, null);
var storeOption = Store/* default */.A.get(option.name) ? JSON.parse(Store/* default */.A.get(option.name)) : null;
// 如果选项不存在 || 版本不一致 时重置选项
if (storeOption === null || !storeOption['version'] || storeOption['version'] < option.version) {
Store/* default */.A.set(option.name, JSON.stringify(option));
storeOption = option;
}
this.registerBoolOption(storeOption);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
/**
* 在 Greasy Fork 脚本详情页中加载选项
*
* @param scriptId 脚本 ID
* @param loadOptionContentFn 加载选项内容的函数
*/
}, {
key: "loadInGreasyfork",
value: function loadInGreasyfork(scriptId, loadOptionContentFn) {
// 非脚本详情页结束
if (location.host !== 'greasyfork.org' || location.href.indexOf('/scripts/' + scriptId) == -1) {
return;
}
var selector = {
scriptLinks: '#script-links',
scriptOptions: '#script-options',
scriptContent: '#script-content'
};
var $body = $(document.body),
$scriptLinks = $(selector.scriptLinks),
$scriptContent = $(selector.scriptContent);
// 添加“脚本设置”选项卡和点击事件
$scriptLinks.children('li:eq(0)').after("<li><a href=\"javascript:;\" id=\"script-options\">\u811A\u672C\u8BBE\u7F6E</a></li>");
$body.on('click', selector.scriptOptions, function () {
// 移除其他已选中选项的样式
var $currentLi = $scriptLinks.children('li.current');
$currentLi.html("<a href=\"".concat(location.href, "\">").concat($currentLi.text(), "</a>"));
$currentLi.removeClass('current');
// 给“脚本设置”选项卡添加选中选项的样式
var $scriptOptions = $(selector.scriptOptions);
$scriptOptions.parent().addClass('current');
loadOptionContentFn($scriptContent);
});
}
}]);
}();
;// ./v2ex-replies-pro/src/Options.ts
var _Options;
function Options_typeof(o) { "@babel/helpers - typeof"; return Options_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, Options_typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function Options_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function Options_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, Options_toPropertyKey(o.key), o); } }
function Options_createClass(e, r, t) { return r && Options_defineProperties(e.prototype, r), t && Options_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _defineProperty(e, r, t) { return (r = Options_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function Options_toPropertyKey(t) { var i = Options_toPrimitive(t, "string"); return "symbol" == Options_typeof(i) ? i : i + ""; }
function Options_toPrimitive(t, r) { if ("object" != Options_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != Options_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var Options = /*#__PURE__*/function () {
function Options() {
Options_classCallCheck(this, Options);
}
return Options_createClass(Options, null, [{
key: "registerAll",
value:
/**
* 注册所有选项
*/
function registerAll() {
CommonOptions.registerAll(this.options, 'https://www.v2ex.com/settings');
}
/**
* 在页面中加载选项
*/
}, {
key: "loadInV2ex",
value: function loadInV2ex() {
var _this = this;
if (location.href.indexOf('v2ex.com/settings') == -1) {
return;
}
var selector = {
menuTab: 'a.tab',
currentMenuTab: 'a.tab_current',
scriptOptions: '#script-options',
scriptContent: '#Main .box',
v2exTokenInput: 'input[name="v2exToken"]',
saveOptionsBtn: '#save-options'
},
$body = $(document.body),
$menuTab = $(selector.menuTab);
// 添加脚本设置的选项卡
$menuTab.parent().append("<a id=\"script-options\" class=\"tab\" href=\"javascript:void(0);\">\u811A\u672C\u8BBE\u7F6E</a>");
// 脚本设置选项点击事件
$body.on('click', selector.scriptOptions, function () {
// 移除已选中选项的样式
var $currentMenuTab = $(selector.currentMenuTab);
$currentMenuTab.removeClass('tab_current');
$currentMenuTab.addClass('tab');
// 添加选中选项的样式
var $scriptOptions = $(selector.scriptOptions);
$scriptOptions.removeClass('tab');
$scriptOptions.addClass('tab_current');
// 添加脚本设置的内容
$(selector.scriptContent + ' div:gt(1)').remove();
$(selector.scriptContent).append("\n <form>\n <div class=\"inner\">\n <div class=\"topic_content markdown_body\">\n <!--<p><a href=\"https://www.v2ex.com/settings/tokens\" target=\"_blank\">\u83B7\u53D6 V2EX Token</a></p> -->\n </div>\n <div class=\"sep20\"></div>\n <div class=\"social-settings-form\">\n <div>\n <div><a href=\"https://www.v2ex.com/settings/tokens\" target=\"_blank\">V2EX Token</a>\uFF1A</div>\n <input type=\"password\" class=\"sl\" name=\"v2exToken\" value=\"".concat(JSON.parse(Store/* default */.A.get(_this.Keys.v2exToken)).value, "\">\n </div>\n </div>\n </div>\n <div class=\"cell_ops\">\n <input id=\"save-options\" type=\"submit\" class=\"super normal button\" value=\"Save\">\n </div>\n </form>\n "));
$body.on('click', selector.saveOptionsBtn, function () {
var token = $(selector.v2exTokenInput).val();
Store/* default */.A.set(_this.Keys.v2exToken, JSON.stringify(_objectSpread(_objectSpread({}, JSON.parse(Store/* default */.A.get(_this.Keys.v2exToken))), {
value: token
})));
layer.msg('保存成功');
return false;
});
});
}
}]);
}();
_Options = Options;
/**
* 选项 Key
*/
_defineProperty(Options, "Keys", {
v2exToken: 'v2exToken'
});
/**
* 选项
* @private
*/
_defineProperty(Options, "options", [{
label: 'V2EX Token',
name: _Options.Keys.v2exToken,
version: 1,
value: '',
menuCmdId: null
}]);
/***/ }),
/***/ 487:
/***/ ((__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) => {
/* harmony import */ var _Reply__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(842);
/* harmony import */ var _Options__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(481);
// ==UserScript==
// @name V2EX 主题回复增强
// @namespace http://tampermonkey.net/
// @version 0.1.2
// @description 增强 V2EX 主题的回复。
// @author duanluan
// @copyright 2022, duanluan (https://github.com/duanluan)
// @license Apache-2.0; https://www.apache.org/licenses/LICENSE-2.0.txt
// @match *://*.v2ex.com/*
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/moment.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/locale/zh-cn.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/winbox.bundle.min.js
// @resource css https://cdn.jsdelivr.net/npm/[email protected]/src/theme/default/layer.min.css
// @require https://cdn.jsdelivr.net/npm/[email protected]/src/layer.min.js
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_getResourceText
// @grant GM_addStyle
// ==/UserScript==
// ==OpenUserJS==
// @author duanluan
// @updateURL https://raw.kkgithub.com/duanluan/tampermonkey-scripts/main/v2ex-replies-pro/dist/core-socialist-values.user.js
// ==/OpenUserJS==
(function () {
'use strict';
// 加载 CSS
GM_addStyle(GM_getResourceText('css'));
// layer 图标未知原因失效,手动添加样式
$(document.head).append("<style>\n .layui-layer-ico{background:url('https://cdn.jsdelivr.net/npm/[email protected]/dist/theme/default/icon.png') no-repeat}\n .layui-layer-ico1{background-position:-30px 0}\n .layui-layer-ico2{background-position:-60px 0}\n .layui-layer-ico3{background-position:-90px 0}\n .layui-layer-ico4{background-position:-120px 0}\n .layui-layer-ico5{background-position:-150px 0}\n .layui-layer-ico6{background-position:-180px 0}\n </style>");
_Options__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.registerAll();
_Options__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.loadInV2ex();
_Reply__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.run();
})();
/***/ }),
/***/ 842:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
A: () => (/* binding */ Reply)
});
;// ./utils/src/gm/enum/HttpDataType.ts
var HttpDataType = /*#__PURE__*/function (HttpDataType) {
HttpDataType["JSON"] = "JSON";
return HttpDataType;
}({});
;// ./utils/src/gm/Request.ts
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var Request = /*#__PURE__*/function () {
function Request() {
_classCallCheck(this, Request);
}
return _createClass(Request, null, [{
key: "get",
value: function () {
var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(option) {
var onload1;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
option['method'] = 'GET';
// 同步时返回 Promise
if (!option.synchronous) {
_context.n = 1;
break;
}
return _context.a(2, new Promise(function (resolve, reject) {
GM_xmlhttpRequest(_objectSpread(_objectSpread({}, option), {}, {
onload: function onload(response) {
resolve(option.dataType === HttpDataType.JSON ? JSON.parse(response.responseText) : response.responseText);
},
onerror: function onerror(error) {
reject(error);
}
}));
}));
case 1:
onload1 = function onload1(details) {
var response;
if (option.dataType === HttpDataType.JSON) {
response = JSON.parse(details.responseText);
} else {
response = details.response;
}
option.onload(response);
};
GM_xmlhttpRequest(_objectSpread(_objectSpread({}, option), {}, {
onload: onload1
}));
case 2:
return _context.a(2);
}
}, _callee);
}));
function get(_x) {
return _get.apply(this, arguments);
}
return get;
}()
}]);
}();
;// ./utils/src/gm/Info.ts
function Info_typeof(o) { "@babel/helpers - typeof"; return Info_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, Info_typeof(o); }
function Info_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function Info_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, Info_toPropertyKey(o.key), o); } }
function Info_createClass(e, r, t) { return r && Info_defineProperties(e.prototype, r), t && Info_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function Info_toPropertyKey(t) { var i = Info_toPrimitive(t, "string"); return "symbol" == Info_typeof(i) ? i : i + ""; }
function Info_toPrimitive(t, r) { if ("object" != Info_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != Info_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* 获取脚本信息
*/
var Info = /*#__PURE__*/function () {
function Info() {
Info_classCallCheck(this, Info);
}
return Info_createClass(Info, null, [{
key: "get",
value: function get() {
return GM_info.script;
}
}, {
key: "getName",
value: function getName() {
return this.get().name;
}
}, {
key: "getVersion",
value: function getVersion() {
return this.get().version;
}
}]);
}();
// EXTERNAL MODULE: ./utils/src/gm/Store.ts
var Store = __webpack_require__(307);
// EXTERNAL MODULE: ./v2ex-replies-pro/src/Options.ts + 2 modules
var Options = __webpack_require__(481);
;// ./v2ex-replies-pro/src/api/V2ex.ts
function V2ex_typeof(o) { "@babel/helpers - typeof"; return V2ex_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, V2ex_typeof(o); }
function V2ex_regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return V2ex_regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (V2ex_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, V2ex_regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, V2ex_regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), V2ex_regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", V2ex_regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), V2ex_regeneratorDefine2(u), V2ex_regeneratorDefine2(u, o, "Generator"), V2ex_regeneratorDefine2(u, n, function () { return this; }), V2ex_regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (V2ex_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function V2ex_regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } V2ex_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { V2ex_regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, V2ex_regeneratorDefine2(e, r, n, t); }
function V2ex_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function V2ex_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { V2ex_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { V2ex_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
function V2ex_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function V2ex_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, V2ex_toPropertyKey(o.key), o); } }
function V2ex_createClass(e, r, t) { return r && V2ex_defineProperties(e.prototype, r), t && V2ex_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function V2ex_defineProperty(e, r, t) { return (r = V2ex_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function V2ex_toPropertyKey(t) { var i = V2ex_toPrimitive(t, "string"); return "symbol" == V2ex_typeof(i) ? i : i + ""; }
function V2ex_toPrimitive(t, r) { if ("object" != V2ex_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != V2ex_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var V2ex = /*#__PURE__*/function () {
function V2ex() {
V2ex_classCallCheck(this, V2ex);
}
return V2ex_createClass(V2ex, null, [{
key: "checkToken",
value: (
/**
* 检查 Token 是否有效
*/
function () {
var _checkToken = V2ex_asyncToGenerator(/*#__PURE__*/V2ex_regenerator().m(function _callee() {
var token, result;
return V2ex_regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
token = JSON.parse(Store/* default */.A.get(Options/* default */.A.Keys.v2exToken)).value;
if (!(!token && location.href.indexOf('v2ex.com/settings') == -1)) {
_context.n = 1;
break;
}
layer.msg('请先在“脚本设置”中填写 Token!', {
icon: 4,
offset: 'rb'
}, function () {
window.open('https://www.v2ex.com/settings', '_blank');
});
return _context.a(2, false);
case 1:
_context.n = 2;
return Request.get({
url: this.BASE_URL + 'token',
dataType: HttpDataType.JSON,
synchronous: true,
headers: {
'Authorization': 'Bearer ' + token
}
});
case 2:
result = _context.v;
if (result['success']) {
_context.n = 3;
break;
}
layer.msg(Info.getName() + ":" + result['message'], {
icon: 2,
offset: 'rb',
time: 5000
});
return _context.a(2, false);
case 3:
return _context.a(2, true);
}
}, _callee, this);
}));
function checkToken() {
return _checkToken.apply(this, arguments);
}
return checkToken;
}()
/**
* 获取主题回复
* @param topicId 主题 ID
* @param page 页码
*/
)
}, {
key: "getReplies",
value: (function () {
var _getReplies = V2ex_asyncToGenerator(/*#__PURE__*/V2ex_regenerator().m(function _callee2(topicId, page) {
var result;
return V2ex_regenerator().w(function (_context2) {
while (1) switch (_context2.n) {
case 0:
_context2.n = 1;
return Request.get({
url: this.BASE_URL + 'topics/' + topicId + '/replies' + (page ? '?p=' + page : ''),
dataType: HttpDataType.JSON,
synchronous: true,
headers: {
'Authorization': 'Bearer ' + JSON.parse(Store/* default */.A.get(Options/* default */.A.Keys.v2exToken)).value
}
});
case 1:
result = _context2.v;
if (result['success']) {
_context2.n = 2;
break;
}
console.warn(Info.getName() + ":" + result['message']);
return _context2.a(2);
case 2:
return _context2.a(2, result['result']);
}
}, _callee2, this);
}));
function getReplies(_x, _x2) {
return _getReplies.apply(this, arguments);
}
return getReplies;
}())
}]);
}();
V2ex_defineProperty(V2ex, "BASE_URL", 'https://www.v2ex.com/api/v2/');
;// ./v2ex-replies-pro/src/Reply.ts
function Reply_typeof(o) { "@babel/helpers - typeof"; return Reply_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, Reply_typeof(o); }
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(Reply_typeof(e) + " is not iterable"); }
function Reply_regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return Reply_regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (Reply_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, Reply_regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, Reply_regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), Reply_regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", Reply_regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), Reply_regeneratorDefine2(u), Reply_regeneratorDefine2(u, o, "Generator"), Reply_regeneratorDefine2(u, n, function () { return this; }), Reply_regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (Reply_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function Reply_regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } Reply_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { Reply_regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, Reply_regeneratorDefine2(e, r, n, t); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function Reply_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function Reply_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { Reply_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { Reply_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
function Reply_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function Reply_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, Reply_toPropertyKey(o.key), o); } }
function Reply_createClass(e, r, t) { return r && Reply_defineProperties(e.prototype, r), t && Reply_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function Reply_toPropertyKey(t) { var i = Reply_toPrimitive(t, "string"); return "symbol" == Reply_typeof(i) ? i : i + ""; }
function Reply_toPrimitive(t, r) { if ("object" != Reply_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != Reply_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var Reply = /*#__PURE__*/function () {
function Reply() {
Reply_classCallCheck(this, Reply);
}
return Reply_createClass(Reply, null, [{
key: "run",
value: function () {
var _run = Reply_asyncToGenerator(/*#__PURE__*/Reply_regenerator().m(function _callee() {
var selector, $body, $head, $repliesNumber, $atLinks, atLinkReg, atLinkMatcher, atLinkAllMatcher, repliesNumber, replies, i, userAndAtUserReplyHtml, _iterator, _step, _loop, _iterator2, _step2, _loop2, _t, _t2, _t3, _t4, _t5;
return Reply_regenerator().w(function (_context3) {
while (1) switch (_context3.p = _context3.n) {
case 0:
if (!(location.href.indexOf('v2ex.com/t/') === -1)) {
_context3.n = 1;
break;
}
return _context3.a(2);
case 1:
_context3.n = 2;
return V2ex.checkToken();
case 2:
if (_context3.v) {
_context3.n = 3;
break;
}
return _context3.a(2);
case 3:
selector = {
// 回复数
repliesNumber: '#Main > .box:eq(1) .gray',
// 回复
repliesDiv: '#Main > .box:eq(1) div[id^="r_"]',
// @ 链接
atLinks: '.reply_content a[href^="/member/"]',
// 点击的回复
clickedReply: '.clicked-reply',
// 讨论弹窗
taSay: '.ta-say',
// 讨论弹窗的标题
taSayDrag: '.ta-say .wb-drag',
// 讨论弹窗的内容
taSayBody: '.ta-say .wb-body',
// 讨论弹窗的回复
taSayRepliesDiv: '.ta-say .wb-body div[id^="r_"]'
}, $body = $(document.body), $head = $(document.head), $repliesNumber = $(selector.repliesNumber), $atLinks = $(selector.atLinks), atLinkReg = '@<a href="\\/member\\/.+?">(.+?)<\\/a>', atLinkMatcher = new RegExp(atLinkReg), atLinkAllMatcher = new RegExp(atLinkReg, 'g'); // 根据回复数获取所有回复
repliesNumber = $repliesNumber.text().substring(0, $repliesNumber.text().indexOf('条'));
replies = [];
i = 1;
case 4:
if (!(i <= Math.ceil(Number(repliesNumber) / 20))) {
_context3.n = 7;
break;
}
_t = replies.push;
_t2 = replies;
_t3 = _toConsumableArray;
_context3.n = 5;
return V2ex.getReplies(topicId, i);
case 5:
_t.apply.call(_t, _t2, _t3(_context3.v));
case 6:
i++;
_context3.n = 4;
break;
case 7:
// 最后一个回复加上底边框
$(selector.repliesDiv + ':eq(-1)').css('border-bottom', $(selector.repliesDiv + ':eq(-2)').css('border-bottom'));
// 用户和 @用户的回复的 HTML:{'用户名': ['用户的回复 HTML', '@用户的回复 HTML']}
userAndAtUserReplyHtml = {}; // 循环 @用户名,获取他的回复和艾特他的回复
_iterator = _createForOfIteratorHelper($atLinks.toArray());
_context3.p = 8;
_loop = /*#__PURE__*/Reply_regenerator().m(function _loop() {
var atLink, username, _i, _replies, _reply$content_render, reply, replyId, replyHtml, $replyHtml;
return Reply_regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
atLink = _step.value;
username = $(atLink).text();
userAndAtUserReplyHtml[username] = [];
_i = 0, _replies = replies;
case 1:
if (!(_i < _replies.length)) {
_context.n = 4;
break;
}
reply = _replies[_i];
if (!(reply.member.username != username && !((_reply$content_render = reply.content_rendered.match(atLinkAllMatcher)) !== null && _reply$content_render !== void 0 && _reply$content_render.some(function (item) {
var _item$match;
return ((_item$match = item.match(atLinkMatcher)) === null || _item$match === void 0 ? void 0 : _item$match[1]) == username;
})))) {
_context.n = 2;
break;
}
return _context.a(3, 3);
case 2:
replyId = reply.id;
replyHtml = $('#r_' + replyId).prop('outerHTML'), $replyHtml = $(replyHtml); // 修改 html 的 id,追加 _1
$replyHtml.attr('id', $replyHtml.attr('id') + '_1');
// 如果 html 中的 a 链接没有 target 属性或 target 属性不为 _blank,则添加 target="_blank"
$replyHtml.find('a').each(function (i, a) {
if (!a.target || a.target !== '_blank') {
a.target = '_blank';
}
});
userAndAtUserReplyHtml[username].push($replyHtml.prop('outerHTML'));
case 3:
_i++;
_context.n = 1;
break;
case 4:
return _context.a(2);
}
}, _loop);
});
_iterator.s();
case 9:
if ((_step = _iterator.n()).done) {
_context3.n = 11;
break;
}
return _context3.d(_regeneratorValues(_loop()), 10);
case 10:
_context3.n = 9;
break;
case 11:
_context3.n = 13;
break;
case 12:
_context3.p = 12;
_t4 = _context3.v;
_iterator.e(_t4);
case 13:
_context3.p = 13;
_iterator.f();
return _context3.f(13);
case 14:
// 添加弹窗样式
$head.append("<style>\n ".concat(selector.clickedReply, " {\n border: 2px solid !important; \n }\n ").concat(selector.taSay, " {\n border-shadow: 0 14px 12px rgb(0 0 0 / 25%), 0 10px 10px rgb(0 0 0 / 22%) !important\n }\n ").concat(selector.taSayDrag, " {\n background-color: #e2e2e2 !important;\n color: #666\n }\n ").concat(selector.taSayBody, " {\n padding-bottom: 10px\n }\n </style>"));
// 循环 @用户名
_iterator2 = _createForOfIteratorHelper($atLinks.toArray());
_context3.p = 15;
_loop2 = /*#__PURE__*/Reply_regenerator().m(function _loop2() {
var atLink, $atLink;
return Reply_regenerator().w(function (_context2) {
while (1) switch (_context2.n) {
case 0:
atLink = _step2.value;
$atLink = $(atLink); // @用户名点击时显示讨论弹窗
$atLink.on('click', function (e) {
e.preventDefault();
// TODO 如果已经打开了讨论弹窗,跳过
// 移除之前加粗的回复的边框
$(selector.clickedReply).removeClass(selector.clickedReply.substring(1));
// 加粗点击 @用户名的那条回复的边框
var $cell = $atLink.parents('.cell');
$cell.addClass(selector.clickedReply.substring(1));
// 跳转到那条回复
var targetY = $cell.offset().top - $(window).height() / 2;
window.scrollTo({
top: targetY,
behavior: 'smooth'
});
var username = $atLink.text();
if (Reply.winbox) {
Reply.winbox.close();
}
Reply.winbox = new WinBox({
"class": selector.taSay.substring(1),
title: "".concat(username, " \u5728\u8BA8\u8BBA\u2026\u2026"),
x: localStorage.getItem('ta_say_x') || 'right',
y: localStorage.getItem('ta_say_y') || 'bottom',
width: localStorage.getItem('ta_say_width') || '540px',
height: localStorage.getItem('ta_say_height') || '70%',
html: "".concat(userAndAtUserReplyHtml[username].join('')),
onresize: function onresize(width, height) {
// 改变窗口大小时记录窗口大小
localStorage.setItem('ta_say_width', width + 'px');
localStorage.setItem('ta_say_height', height + 'px');
},
onmove: function onmove(x, y) {
// 移动窗口时记录窗口位置
localStorage.setItem('ta_say_x', x);
localStorage.setItem('ta_say_y', y);
}
});
// 弹窗中加粗点击 @用户名的那条回复的边框
var $cell1 = $("#".concat($cell.attr('id'), "_1"));
$cell1.addClass(selector.clickedReply.substring(1));
// 跳转到那条回复
var $scrollContainer = $(selector.taSayBody);
var scrollContainer = $scrollContainer[0]; // 获取 DOM 元素
if (scrollContainer) {
// 计算目标 scrollTop 值
var targetScrollTop = $cell1.offset().top - $scrollContainer.offset().top - $scrollContainer.height() / 2;
scrollContainer.scrollTo({
top: targetScrollTop,
behavior: 'smooth'
});
}
});
case 1:
return _context2.a(2);
}
}, _loop2);
});
_iterator2.s();
case 16:
if ((_step2 = _iterator2.n()).done) {
_context3.n = 18;
break;
}
return _context3.d(_regeneratorValues(_loop2()), 17);
case 17:
_context3.n = 16;
break;
case 18:
_context3.n = 20;
break;
case 19:
_context3.p = 19;
_t5 = _context3.v;
_iterator2.e(_t5);
case 20:
_context3.p = 20;
_iterator2.f();
return _context3.f(20);
case 21:
layer.msg('回复增强成功', {
icon: 1 /*, offset: 'rb'*/
});
case 22:
return _context3.a(2);
}
}, _callee, null, [[15, 19, 20, 21], [8, 12, 13, 14]]);
}));
function run() {
return _run.apply(this, arguments);
}
return run;
}()
}]);
}();
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ __webpack_require__(487);
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ __webpack_require__(842);
/******/ var __webpack_exports__ = __webpack_require__(481);
/******/
/******/ })()
;
//# sourceMappingURL=v2ex-replies-pro.user.js.map