// ==UserScript==
// @name anti-redirect
// @author Axetroy
// @collaborator Axetroy
// @description 去除重定向, 支持谷歌/百度/搜狗/360/知乎/贴吧/简书/豆瓣/微博...
// @version 2.18.3
// @update 2020-12-31 09:55:50
// @grant GM_xmlhttpRequest
// @include *www.baidu.com*
// @include *tieba.baidu.com*
// @include *v.baidu.com*
// @include *xueshu.baidu.com*
// @include *www.google.*
// @include *docs.google.*
// @include *mail.google.*
// @include *play.google.*
// @include *youtube.com/watch?v=*
// @include *youtube.com/channel/*
// @include *encrypted.google.com*
// @include *www.so.com*
// @include *www.zhihu.com*
// @include *daily.zhihu.com*
// @include *zhuanlan.zhihu.com*
// @include *weibo.com*
// @include *twitter.com*
// @include *www.sogou.com*
// @include *juejin.im*
// @include *mail.qq.com*
// @include *addons.mozilla.org*
// @include *www.jianshu.com*
// @include *www.douban.com*
// @include *getpocket.com*
// @include *www.dogedoge.com*
// @include *51.ruyo.net*
// @include *steamcommunity.com*
// @include *mijisou.com*
// @include *blog.csdn.net*
// @include *app.yinxiang.com*
// @connect www.baidu.com
// @connect *
// @compatible chrome 完美运行
// @compatible firefox 完美运行
// @supportURL https://axetroy.github.io/
// @run-at document-start
// @contributionURL [email protected]|alipay.com
// @namespace https://greasyfork.org/zh-CN/users/3400-axetroy
// @license Anti 996 License; https://github.com/axetroy/anti-redirect/blob/master/LICENSE
// ==/UserScript==
// Github源码: https://github.com/axetroy/anti-redirect
// 如果这能帮助到你,欢迎在 Github 上点击 star 和 follow.
// 或者在支付宝搜索 " 511118132 " 领取红包
// 你的支持就是我更新的动力
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
__webpack_require__(1);
const app_1 = __webpack_require__(2);
const _51_ruyo_net_1 = __webpack_require__(7);
const addons_mozilla_org_1 = __webpack_require__(8);
const app_yinxiang_com_1 = __webpack_require__(9);
const blog_csdn_net_1 = __webpack_require__(10);
const daily_zhihu_com_1 = __webpack_require__(11);
const docs_google_com_1 = __webpack_require__(12);
const getpocket_com_1 = __webpack_require__(13);
const gmail_google_com_1 = __webpack_require__(14);
const juejin_com_1 = __webpack_require__(15);
const mail_qq_com_1 = __webpack_require__(16);
const mijisou_com_1 = __webpack_require__(17);
const play_google_com_1 = __webpack_require__(18);
const steamcommunity_com_1 = __webpack_require__(19);
const tieba_baidu_com_1 = __webpack_require__(20);
const twitter_com_1 = __webpack_require__(21);
const video_baidu_com_1 = __webpack_require__(22);
const weibo_com_1 = __webpack_require__(24);
const www_baidu_com_1 = __webpack_require__(25);
const www_dogedoge_com_1 = __webpack_require__(26);
const www_douban_com_1 = __webpack_require__(27);
const www_google_com_1 = __webpack_require__(28);
const www_jianshu_com_1 = __webpack_require__(29);
const www_so_com_1 = __webpack_require__(30);
const www_sogou_com_1 = __webpack_require__(31);
const www_youtube_com_1 = __webpack_require__(32);
const www_zhihu_com_1 = __webpack_require__(33);
const xueshu_baidu_com_1 = __webpack_require__(34);
const zhuanlan_zhihu_com_1 = __webpack_require__(35);
const gm_http_1 = __webpack_require__(23);
const app = new app_1.App();
const isDebug = "production" !== "production";
gm_http_1.default.setConfig({ debug: isDebug });
app
.setConfig({ isDebug })
.registerProvider([
{
// 测试地址: https://www.zhihu.com/question/25258775
name: "知乎",
test: /www\.zhihu\.com/,
provider: www_zhihu_com_1.ZhihuProvider,
},
{
// 测试地址: https://zhuanlan.zhihu.com/p/20549978
name: "知乎专栏",
test: /zhuanlan\.zhihu\.com/,
provider: zhuanlan_zhihu_com_1.ZhihuZhuanlanProvider,
},
{
// 测试地址:
name: "知乎日报",
test: /daily\.zhihu\.com/,
provider: daily_zhihu_com_1.ZhihuDailyProvider,
},
{
name: "Google搜索",
test: /\w+\.google\./,
provider: www_google_com_1.GoogleProvider,
},
{
// 测试地址: https://docs.google.com/spreadsheets/d/1TFcEXMcKrwoIAECIVyBU0GPoSmRqZ7A0VBvqeKYVSww/htmlview
name: "Google Docs",
test: /docs\.google\.com/,
provider: docs_google_com_1.GoogleDocsProvider,
},
{
name: "Gmail",
test: /mail\.google\.com/,
provider: gmail_google_com_1.GmailProvider,
},
{
// 测试地址: https://play.google.com/store/movies/details/%E7%A7%BB%E5%8B%95%E8%BF%B7%E5%AE%AE_%E6%AD%BB%E4%BA%A1%E8%A7%A3%E8%97%A5?id=YNy7gRqwtMk
name: "Google Play",
test: /play\.google\.com/,
provider: play_google_com_1.GooglePlayProvider,
},
{
// 测试地址: https://www.youtube.com/watch?v=XTXSRRSv1bY
name: "Google Youtube",
test: /www\.youtube\.com/,
provider: www_youtube_com_1.YoutubeProvider,
},
{
// 测试地址: https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&q=chrome
name: "360搜索",
test: /www\.so\.com/,
provider: www_so_com_1.SoProvider,
},
{
name: "新浪微博",
test: /\.weibo\.com/,
provider: weibo_com_1.WeboProvider,
},
{
name: "Twitter",
test: /twitter\.com/,
provider: twitter_com_1.TwitterProvider,
},
{
// 测试: http://www.sogou.com/web?query=chrome&_asf=www.sogou.com&_ast=&w=01019900&p=40040100&ie=utf8&from=index-nologin&s_from=index&sut=1527&sst0=1504347367611&lkt=0%2C0%2C0&sugsuv=00091651B48CA45F593B61A29B131405&sugtime=1504347367611
name: "搜狗搜索",
test: /www\.sogou\.com/,
provider: www_sogou_com_1.SoGouProvider,
},
{
// 测试: https://www.baidu.com/s?wd=chrome&rsv_spt=1&rsv_iqid=0xcb136237000ed40e&issp=1&f=8&rsv_bp=0&rsv_idx=2&ie=utf-8&tn=baidulocal&rsv_enter=1&rsv_sug3=7&rsv_sug1=7&rsv_sug7=101&rsv_sug2=0&inputT=813&rsv_sug4=989×tamp=1504349229266&rn=50&vf_bl=1
name: "百度搜索",
test: /www\.baidu\.com/,
provider: www_baidu_com_1.BaiduProvider,
},
{
// 测试: https://www.baidu.com/s?wd=chrome&pn=20&oq=chrome&tn=baiduhome_pg&ie=utf-8&usm=3&rsv_idx=2&rsv_pq=e043900d0000752d&rsv_t=6bb0UqEwp2Tle6TAMBDlU3Wg%2BSxoqvvOhZKyQgM%2BVQP8Gc54QZLhcDcj62eGfNG75aq5&rsv_page=1
name: "百度视频",
test: /v\.baidu\.com/,
provider: video_baidu_com_1.BaiduVideoProvider,
},
{
// 测试: http://xueshu.baidu.com/s?wd=paperuri%3A%28ae4d6b5da05eca552dab05aeefb966e6%29&ie=utf-8&filter=sc_long_sign&sc_ks_para=q%3D%E2%80%9C%E4%BA%92%E8%81%94%E7%BD%91%2B%E5%81%A5%E5%BA%B7%E7%AE%A1%E7%90%86%E2%80%9D%E6%A8%A1%E5%BC%8F%E6%8E%A2%E8%AE%A8%E5%8F%8A%E5%85%B6%E5%BA%94%E7%94%A8&tn=SE_baiduxueshu_c1gjeupa
name: "百度学术",
test: /xueshu\.baidu\.com/,
provider: xueshu_baidu_com_1.BaiduXueshuProvider,
},
{
// 测试地址: http://tieba.baidu.com/p/5300844180
name: "百度贴吧",
test: /tieba\.baidu\.com/,
provider: tieba_baidu_com_1.TiebaProvider,
},
{
// 测试地址: https://juejin.im/entry/59ac8fa551882524241a8802?utm_source=gold_browser_extension
name: "掘金",
test: /juejin\.im/,
provider: juejin_com_1.JuejinProvider,
},
{
name: "QQ邮箱",
test: /mail\.qq\.com/,
provider: mail_qq_com_1.QQMailProvider,
},
{
// 测试地址: https://addons.mozilla.org/zh-CN/firefox/addon/evernote-web-clipper/
name: "Mozilla",
test: /addons\.mozilla\.org/,
provider: addons_mozilla_org_1.MozillaProvider,
},
{
// 测试地址: https://www.jianshu.com/p/979776ca44b8
// https://www.jianshu.com/p/fc8abc65bbb2
name: "简书",
test: /www\.jianshu\.com/,
provider: www_jianshu_com_1.JianShuProvider,
},
{
// 测试地址: https://www.douban.com/doulist/240962/
// 测试地址: https://www.douban.com/search?cat=1002&q=%E9%BB%91%E9%95%9C
name: "豆瓣",
test: /douban\.com/,
provider: www_douban_com_1.DouBanProvider,
},
{
// 测试地址: https://getpocket.com/a/recommended/
// 需要登陆
name: "Pocket",
test: /getpocket\.com/,
provider: getpocket_com_1.PocketProvider,
},
{
// 测试地址: https://www.dogedoge.com/results?q=chrome
name: "DogeDoge",
test: /www\.dogedoge\.com/,
provider: www_dogedoge_com_1.DogeDogeProvider,
},
{
// 测试地址: https://51.ruyo.net/15053.html
name: "Ruyo",
test: /51\.ruyo\.net/,
provider: _51_ruyo_net_1.RuyoProvider,
},
{
// 测试地址: https://steamcommunity.com/sharedfiles/filedetails/?id=1311535531
name: "Steam",
test: /steamcommunity\.com/,
provider: steamcommunity_com_1.SteamProvider,
},
{
// 测试地址: https://mijisou.com/?q=chrome&category_general=on&time_range=&language=zh-CN&pageno=1
name: "秘迹",
test: /mijisou\.com/,
provider: mijisou_com_1.MiJiProvider,
},
{
// 测试地址: https://github.com/axetroy/anti-redirect/issues/350
name: "CSDN",
test: /blog\.csdn\.net/,
provider: blog_csdn_net_1.CSDNProvider,
},
{
// 测试地址: https://github.com/axetroy/anti-redirect/issues/350
name: "印象笔记",
test: /app\.yinxiang\.com/,
provider: app_yinxiang_com_1.YinXiangProvider,
},
])
.bootstrap();
/***/ }),
/* 1 */
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
/*! *****************************************************************************
Copyright (C) Microsoft. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var Reflect;
(function (Reflect) {
// Metadata Proposal
// https://rbuckton.github.io/reflect-metadata/
(function (factory) {
var root = typeof __webpack_require__.g === "object" ? __webpack_require__.g :
typeof self === "object" ? self :
typeof this === "object" ? this :
Function("return this;")();
var exporter = makeExporter(Reflect);
if (typeof root.Reflect === "undefined") {
root.Reflect = Reflect;
}
else {
exporter = makeExporter(root.Reflect, exporter);
}
factory(exporter);
function makeExporter(target, previous) {
return function (key, value) {
if (typeof target[key] !== "function") {
Object.defineProperty(target, key, { configurable: true, writable: true, value: value });
}
if (previous)
previous(key, value);
};
}
})(function (exporter) {
var hasOwn = Object.prototype.hasOwnProperty;
// feature test for Symbol support
var supportsSymbol = typeof Symbol === "function";
var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
var supportsCreate = typeof Object.create === "function"; // feature test for Object.create support
var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support
var downLevel = !supportsCreate && !supportsProto;
var HashMap = {
// create an object in dictionary mode (a.k.a. "slow" mode in v8)
create: supportsCreate
? function () { return MakeDictionary(Object.create(null)); }
: supportsProto
? function () { return MakeDictionary({ __proto__: null }); }
: function () { return MakeDictionary({}); },
has: downLevel
? function (map, key) { return hasOwn.call(map, key); }
: function (map, key) { return key in map; },
get: downLevel
? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; }
: function (map, key) { return map[key]; },
};
// Load global or shim versions of Map, Set, and WeakMap
var functionPrototype = Object.getPrototypeOf(Function);
var usePolyfill = typeof process === "object" && process.env && process.env["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true";
var _Map = !usePolyfill && typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
var _Set = !usePolyfill && typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
var _WeakMap = !usePolyfill && typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
// [[Metadata]] internal slot
// https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots
var Metadata = new _WeakMap();
/**
* Applies a set of decorators to a property of a target object.
* @param decorators An array of decorators.
* @param target The target object.
* @param propertyKey (Optional) The property key to decorate.
* @param attributes (Optional) The property descriptor for the target key.
* @remarks Decorators are applied in reverse order.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* Example = Reflect.decorate(decoratorsArray, Example);
*
* // property (on constructor)
* Reflect.decorate(decoratorsArray, Example, "staticProperty");
*
* // property (on prototype)
* Reflect.decorate(decoratorsArray, Example.prototype, "property");
*
* // method (on constructor)
* Object.defineProperty(Example, "staticMethod",
* Reflect.decorate(decoratorsArray, Example, "staticMethod",
* Object.getOwnPropertyDescriptor(Example, "staticMethod")));
*
* // method (on prototype)
* Object.defineProperty(Example.prototype, "method",
* Reflect.decorate(decoratorsArray, Example.prototype, "method",
* Object.getOwnPropertyDescriptor(Example.prototype, "method")));
*
*/
function decorate(decorators, target, propertyKey, attributes) {
if (!IsUndefined(propertyKey)) {
if (!IsArray(decorators))
throw new TypeError();
if (!IsObject(target))
throw new TypeError();
if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
throw new TypeError();
if (IsNull(attributes))
attributes = undefined;
propertyKey = ToPropertyKey(propertyKey);
return DecorateProperty(decorators, target, propertyKey, attributes);
}
else {
if (!IsArray(decorators))
throw new TypeError();
if (!IsConstructor(target))
throw new TypeError();
return DecorateConstructor(decorators, target);
}
}
exporter("decorate", decorate);
// 4.1.2 Reflect.metadata(metadataKey, metadataValue)
// https://rbuckton.github.io/reflect-metadata/#reflect.metadata
/**
* A default metadata decorator factory that can be used on a class, class member, or parameter.
* @param metadataKey The key for the metadata entry.
* @param metadataValue The value for the metadata entry.
* @returns A decorator function.
* @remarks
* If `metadataKey` is already defined for the target and target key, the
* metadataValue for that key will be overwritten.
* @example
*
* // constructor
* @Reflect.metadata(key, value)
* class Example {
* }
*
* // property (on constructor, TypeScript only)
* class Example {
* @Reflect.metadata(key, value)
* static staticProperty;
* }
*
* // property (on prototype, TypeScript only)
* class Example {
* @Reflect.metadata(key, value)
* property;
* }
*
* // method (on constructor)
* class Example {
* @Reflect.metadata(key, value)
* static staticMethod() { }
* }
*
* // method (on prototype)
* class Example {
* @Reflect.metadata(key, value)
* method() { }
* }
*
*/
function metadata(metadataKey, metadataValue) {
function decorator(target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
throw new TypeError();
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
}
return decorator;
}
exporter("metadata", metadata);
/**
* Define a unique metadata entry on the target.
* @param metadataKey A key used to store and retrieve metadata.
* @param metadataValue A value that contains attached metadata.
* @param target The target object on which to define metadata.
* @param propertyKey (Optional) The property key for the target.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* Reflect.defineMetadata("custom:annotation", options, Example);
*
* // property (on constructor)
* Reflect.defineMetadata("custom:annotation", options, Example, "staticProperty");
*
* // property (on prototype)
* Reflect.defineMetadata("custom:annotation", options, Example.prototype, "property");
*
* // method (on constructor)
* Reflect.defineMetadata("custom:annotation", options, Example, "staticMethod");
*
* // method (on prototype)
* Reflect.defineMetadata("custom:annotation", options, Example.prototype, "method");
*
* // decorator factory as metadata-producing annotation.
* function MyAnnotation(options): Decorator {
* return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
* }
*
*/
function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
}
exporter("defineMetadata", defineMetadata);
/**
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.hasMetadata("custom:annotation", Example);
*
* // property (on constructor)
* result = Reflect.hasMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.hasMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.hasMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.hasMetadata("custom:annotation", Example.prototype, "method");
*
*/
function hasMetadata(metadataKey, target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryHasMetadata(metadataKey, target, propertyKey);
}
exporter("hasMetadata", hasMetadata);
/**
* Gets a value indicating whether the target object has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.hasOwnMetadata("custom:annotation", Example);
*
* // property (on constructor)
* result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "method");
*
*/
function hasOwnMetadata(metadataKey, target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
}
exporter("hasOwnMetadata", hasOwnMetadata);
/**
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.getMetadata("custom:annotation", Example);
*
* // property (on constructor)
* result = Reflect.getMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getMetadata("custom:annotation", Example.prototype, "method");
*
*/
function getMetadata(metadataKey, target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryGetMetadata(metadataKey, target, propertyKey);
}
exporter("getMetadata", getMetadata);
/**
* Gets the metadata value for the provided metadata key on the target object.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.getOwnMetadata("custom:annotation", Example);
*
* // property (on constructor)
* result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method");
*
*/
function getOwnMetadata(metadataKey, target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
}
exporter("getOwnMetadata", getOwnMetadata);
/**
* Gets the metadata keys defined on the target object or its prototype chain.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns An array of unique metadata keys.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.getMetadataKeys(Example);
*
* // property (on constructor)
* result = Reflect.getMetadataKeys(Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getMetadataKeys(Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getMetadataKeys(Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getMetadataKeys(Example.prototype, "method");
*
*/
function getMetadataKeys(target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryMetadataKeys(target, propertyKey);
}
exporter("getMetadataKeys", getMetadataKeys);
/**
* Gets the unique metadata keys defined on the target object.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns An array of unique metadata keys.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.getOwnMetadataKeys(Example);
*
* // property (on constructor)
* result = Reflect.getOwnMetadataKeys(Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.getOwnMetadataKeys(Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.getOwnMetadataKeys(Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.getOwnMetadataKeys(Example.prototype, "method");
*
*/
function getOwnMetadataKeys(target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
return OrdinaryOwnMetadataKeys(target, propertyKey);
}
exporter("getOwnMetadataKeys", getOwnMetadataKeys);
/**
* Deletes the metadata entry from the target object with the provided key.
* @param metadataKey A key used to store and retrieve metadata.
* @param target The target object on which the metadata is defined.
* @param propertyKey (Optional) The property key for the target.
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
* @example
*
* class Example {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* }
*
* // constructor
* result = Reflect.deleteMetadata("custom:annotation", Example);
*
* // property (on constructor)
* result = Reflect.deleteMetadata("custom:annotation", Example, "staticProperty");
*
* // property (on prototype)
* result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "property");
*
* // method (on constructor)
* result = Reflect.deleteMetadata("custom:annotation", Example, "staticMethod");
*
* // method (on prototype)
* result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "method");
*
*/
function deleteMetadata(metadataKey, target, propertyKey) {
if (!IsObject(target))
throw new TypeError();
if (!IsUndefined(propertyKey))
propertyKey = ToPropertyKey(propertyKey);
var metadataMap = GetOrCreateMetadataMap(target, propertyKey, /*Create*/ false);
if (IsUndefined(metadataMap))
return false;
if (!metadataMap.delete(metadataKey))
return false;
if (metadataMap.size > 0)
return true;
var targetMetadata = Metadata.get(target);
targetMetadata.delete(propertyKey);
if (targetMetadata.size > 0)
return true;
Metadata.delete(target);
return true;
}
exporter("deleteMetadata", deleteMetadata);
function DecorateConstructor(decorators, target) {
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
var decorated = decorator(target);
if (!IsUndefined(decorated) && !IsNull(decorated)) {
if (!IsConstructor(decorated))
throw new TypeError();
target = decorated;
}
}
return target;
}
function DecorateProperty(decorators, target, propertyKey, descriptor) {
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
var decorated = decorator(target, propertyKey, descriptor);
if (!IsUndefined(decorated) && !IsNull(decorated)) {
if (!IsObject(decorated))
throw new TypeError();
descriptor = decorated;
}
}
return descriptor;
}
function GetOrCreateMetadataMap(O, P, Create) {
var targetMetadata = Metadata.get(O);
if (IsUndefined(targetMetadata)) {
if (!Create)
return undefined;
targetMetadata = new _Map();
Metadata.set(O, targetMetadata);
}
var metadataMap = targetMetadata.get(P);
if (IsUndefined(metadataMap)) {
if (!Create)
return undefined;
metadataMap = new _Map();
targetMetadata.set(P, metadataMap);
}
return metadataMap;
}
// 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata
function OrdinaryHasMetadata(MetadataKey, O, P) {
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
if (hasOwn)
return true;
var parent = OrdinaryGetPrototypeOf(O);
if (!IsNull(parent))
return OrdinaryHasMetadata(MetadataKey, parent, P);
return false;
}
// 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);
if (IsUndefined(metadataMap))
return false;
return ToBoolean(metadataMap.has(MetadataKey));
}
// 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata
function OrdinaryGetMetadata(MetadataKey, O, P) {
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
if (hasOwn)
return OrdinaryGetOwnMetadata(MetadataKey, O, P);
var parent = OrdinaryGetPrototypeOf(O);
if (!IsNull(parent))
return OrdinaryGetMetadata(MetadataKey, parent, P);
return undefined;
}
// 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);
if (IsUndefined(metadataMap))
return undefined;
return metadataMap.get(MetadataKey);
}
// 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true);
metadataMap.set(MetadataKey, MetadataValue);
}
// 3.1.6.1 OrdinaryMetadataKeys(O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys
function OrdinaryMetadataKeys(O, P) {
var ownKeys = OrdinaryOwnMetadataKeys(O, P);
var parent = OrdinaryGetPrototypeOf(O);
if (parent === null)
return ownKeys;
var parentKeys = OrdinaryMetadataKeys(parent, P);
if (parentKeys.length <= 0)
return ownKeys;
if (ownKeys.length <= 0)
return parentKeys;
var set = new _Set();
var keys = [];
for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
var key = ownKeys_1[_i];
var hasKey = set.has(key);
if (!hasKey) {
set.add(key);
keys.push(key);
}
}
for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
var key = parentKeys_1[_a];
var hasKey = set.has(key);
if (!hasKey) {
set.add(key);
keys.push(key);
}
}
return keys;
}
// 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)
// https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys
function OrdinaryOwnMetadataKeys(O, P) {
var keys = [];
var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);
if (IsUndefined(metadataMap))
return keys;
var keysObj = metadataMap.keys();
var iterator = GetIterator(keysObj);
var k = 0;
while (true) {
var next = IteratorStep(iterator);
if (!next) {
keys.length = k;
return keys;
}
var nextValue = IteratorValue(next);
try {
keys[k] = nextValue;
}
catch (e) {
try {
IteratorClose(iterator);
}
finally {
throw e;
}
}
k++;
}
}
// 6 ECMAScript Data Typ0es and Values
// https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values
function Type(x) {
if (x === null)
return 1 /* Null */;
switch (typeof x) {
case "undefined": return 0 /* Undefined */;
case "boolean": return 2 /* Boolean */;
case "string": return 3 /* String */;
case "symbol": return 4 /* Symbol */;
case "number": return 5 /* Number */;
case "object": return x === null ? 1 /* Null */ : 6 /* Object */;
default: return 6 /* Object */;
}
}
// 6.1.1 The Undefined Type
// https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type
function IsUndefined(x) {
return x === undefined;
}
// 6.1.2 The Null Type
// https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type
function IsNull(x) {
return x === null;
}
// 6.1.5 The Symbol Type
// https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type
function IsSymbol(x) {
return typeof x === "symbol";
}
// 6.1.7 The Object Type
// https://tc39.github.io/ecma262/#sec-object-type
function IsObject(x) {
return typeof x === "object" ? x !== null : typeof x === "function";
}
// 7.1 Type Conversion
// https://tc39.github.io/ecma262/#sec-type-conversion
// 7.1.1 ToPrimitive(input [, PreferredType])
// https://tc39.github.io/ecma262/#sec-toprimitive
function ToPrimitive(input, PreferredType) {
switch (Type(input)) {
case 0 /* Undefined */: return input;
case 1 /* Null */: return input;
case 2 /* Boolean */: return input;
case 3 /* String */: return input;
case 4 /* Symbol */: return input;
case 5 /* Number */: return input;
}
var hint = PreferredType === 3 /* String */ ? "string" : PreferredType === 5 /* Number */ ? "number" : "default";
var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
if (exoticToPrim !== undefined) {
var result = exoticToPrim.call(input, hint);
if (IsObject(result))
throw new TypeError();
return result;
}
return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
}
// 7.1.1.1 OrdinaryToPrimitive(O, hint)
// https://tc39.github.io/ecma262/#sec-ordinarytoprimitive
function OrdinaryToPrimitive(O, hint) {
if (hint === "string") {
var toString_1 = O.toString;
if (IsCallable(toString_1)) {
var result = toString_1.call(O);
if (!IsObject(result))
return result;
}
var valueOf = O.valueOf;
if (IsCallable(valueOf)) {
var result = valueOf.call(O);
if (!IsObject(result))
return result;
}
}
else {
var valueOf = O.valueOf;
if (IsCallable(valueOf)) {
var result = valueOf.call(O);
if (!IsObject(result))
return result;
}
var toString_2 = O.toString;
if (IsCallable(toString_2)) {
var result = toString_2.call(O);
if (!IsObject(result))
return result;
}
}
throw new TypeError();
}
// 7.1.2 ToBoolean(argument)
// https://tc39.github.io/ecma262/2016/#sec-toboolean
function ToBoolean(argument) {
return !!argument;
}
// 7.1.12 ToString(argument)
// https://tc39.github.io/ecma262/#sec-tostring
function ToString(argument) {
return "" + argument;
}
// 7.1.14 ToPropertyKey(argument)
// https://tc39.github.io/ecma262/#sec-topropertykey
function ToPropertyKey(argument) {
var key = ToPrimitive(argument, 3 /* String */);
if (IsSymbol(key))
return key;
return ToString(key);
}
// 7.2 Testing and Comparison Operations
// https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations
// 7.2.2 IsArray(argument)
// https://tc39.github.io/ecma262/#sec-isarray
function IsArray(argument) {
return Array.isArray
? Array.isArray(argument)
: argument instanceof Object
? argument instanceof Array
: Object.prototype.toString.call(argument) === "[object Array]";
}
// 7.2.3 IsCallable(argument)
// https://tc39.github.io/ecma262/#sec-iscallable
function IsCallable(argument) {
// NOTE: This is an approximation as we cannot check for [[Call]] internal method.
return typeof argument === "function";
}
// 7.2.4 IsConstructor(argument)
// https://tc39.github.io/ecma262/#sec-isconstructor
function IsConstructor(argument) {
// NOTE: This is an approximation as we cannot check for [[Construct]] internal method.
return typeof argument === "function";
}
// 7.2.7 IsPropertyKey(argument)
// https://tc39.github.io/ecma262/#sec-ispropertykey
function IsPropertyKey(argument) {
switch (Type(argument)) {
case 3 /* String */: return true;
case 4 /* Symbol */: return true;
default: return false;
}
}
// 7.3 Operations on Objects
// https://tc39.github.io/ecma262/#sec-operations-on-objects
// 7.3.9 GetMethod(V, P)
// https://tc39.github.io/ecma262/#sec-getmethod
function GetMethod(V, P) {
var func = V[P];
if (func === undefined || func === null)
return undefined;
if (!IsCallable(func))
throw new TypeError();
return func;
}
// 7.4 Operations on Iterator Objects
// https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects
function GetIterator(obj) {
var method = GetMethod(obj, iteratorSymbol);
if (!IsCallable(method))
throw new TypeError(); // from Call
var iterator = method.call(obj);
if (!IsObject(iterator))
throw new TypeError();
return iterator;
}
// 7.4.4 IteratorValue(iterResult)
// https://tc39.github.io/ecma262/2016/#sec-iteratorvalue
function IteratorValue(iterResult) {
return iterResult.value;
}
// 7.4.5 IteratorStep(iterator)
// https://tc39.github.io/ecma262/#sec-iteratorstep
function IteratorStep(iterator) {
var result = iterator.next();
return result.done ? false : result;
}
// 7.4.6 IteratorClose(iterator, completion)
// https://tc39.github.io/ecma262/#sec-iteratorclose
function IteratorClose(iterator) {
var f = iterator["return"];
if (f)
f.call(iterator);
}
// 9.1 Ordinary Object Internal Methods and Internal Slots
// https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots
// 9.1.1.1 OrdinaryGetPrototypeOf(O)
// https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof
function OrdinaryGetPrototypeOf(O) {
var proto = Object.getPrototypeOf(O);
if (typeof O !== "function" || O === functionPrototype)
return proto;
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
// Try to determine the superclass constructor. Compatible implementations
// must either set __proto__ on a subclass constructor to the superclass constructor,
// or ensure each class has a valid `constructor` property on its prototype that
// points back to the constructor.
// If this is not the same as Function.[[Prototype]], then this is definately inherited.
// This is the case when in ES6 or when using __proto__ in a compatible browser.
if (proto !== functionPrototype)
return proto;
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
var prototype = O.prototype;
var prototypeProto = prototype && Object.getPrototypeOf(prototype);
if (prototypeProto == null || prototypeProto === Object.prototype)
return proto;
// If the constructor was not a function, then we cannot determine the heritage.
var constructor = prototypeProto.constructor;
if (typeof constructor !== "function")
return proto;
// If we have some kind of self-reference, then we cannot determine the heritage.
if (constructor === O)
return proto;
// we have a pretty good guess at the heritage.
return constructor;
}
// naive Map shim
function CreateMapPolyfill() {
var cacheSentinel = {};
var arraySentinel = [];
var MapIterator = /** @class */ (function () {
function MapIterator(keys, values, selector) {
this._index = 0;
this._keys = keys;
this._values = values;
this._selector = selector;
}
MapIterator.prototype["@@iterator"] = function () { return this; };
MapIterator.prototype[iteratorSymbol] = function () { return this; };
MapIterator.prototype.next = function () {
var index = this._index;
if (index >= 0 && index < this._keys.length) {
var result = this._selector(this._keys[index], this._values[index]);
if (index + 1 >= this._keys.length) {
this._index = -1;
this._keys = arraySentinel;
this._values = arraySentinel;
}
else {
this._index++;
}
return { value: result, done: false };
}
return { value: undefined, done: true };
};
MapIterator.prototype.throw = function (error) {
if (this._index >= 0) {
this._index = -1;
this._keys = arraySentinel;
this._values = arraySentinel;
}
throw error;
};
MapIterator.prototype.return = function (value) {
if (this._index >= 0) {
this._index = -1;
this._keys = arraySentinel;
this._values = arraySentinel;
}
return { value: value, done: true };
};
return MapIterator;
}());
return /** @class */ (function () {
function Map() {
this._keys = [];
this._values = [];
this._cacheKey = cacheSentinel;
this._cacheIndex = -2;
}
Object.defineProperty(Map.prototype, "size", {
get: function () { return this._keys.length; },
enumerable: true,
configurable: true
});
Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };
Map.prototype.get = function (key) {
var index = this._find(key, /*insert*/ false);
return index >= 0 ? this._values[index] : undefined;
};
Map.prototype.set = function (key, value) {
var index = this._find(key, /*insert*/ true);
this._values[index] = value;
return this;
};
Map.prototype.delete = function (key) {
var index = this._find(key, /*insert*/ false);
if (index >= 0) {
var size = this._keys.length;
for (var i = index + 1; i < size; i++) {
this._keys[i - 1] = this._keys[i];
this._values[i - 1] = this._values[i];
}
this._keys.length--;
this._values.length--;
if (key === this._cacheKey) {
this._cacheKey = cacheSentinel;
this._cacheIndex = -2;
}
return true;
}
return false;
};
Map.prototype.clear = function () {
this._keys.length = 0;
this._values.length = 0;
this._cacheKey = cacheSentinel;
this._cacheIndex = -2;
};
Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };
Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };
Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };
Map.prototype["@@iterator"] = function () { return this.entries(); };
Map.prototype[iteratorSymbol] = function () { return this.entries(); };
Map.prototype._find = function (key, insert) {
if (this._cacheKey !== key) {
this._cacheIndex = this._keys.indexOf(this._cacheKey = key);
}
if (this._cacheIndex < 0 && insert) {
this._cacheIndex = this._keys.length;
this._keys.push(key);
this._values.push(undefined);
}
return this._cacheIndex;
};
return Map;
}());
function getKey(key, _) {
return key;
}
function getValue(_, value) {
return value;
}
function getEntry(key, value) {
return [key, value];
}
}
// naive Set shim
function CreateSetPolyfill() {
return /** @class */ (function () {
function Set() {
this._map = new _Map();
}
Object.defineProperty(Set.prototype, "size", {
get: function () { return this._map.size; },
enumerable: true,
configurable: true
});
Set.prototype.has = function (value) { return this._map.has(value); };
Set.prototype.add = function (value) { return this._map.set(value, value), this; };
Set.prototype.delete = function (value) { return this._map.delete(value); };
Set.prototype.clear = function () { this._map.clear(); };
Set.prototype.keys = function () { return this._map.keys(); };
Set.prototype.values = function () { return this._map.values(); };
Set.prototype.entries = function () { return this._map.entries(); };
Set.prototype["@@iterator"] = function () { return this.keys(); };
Set.prototype[iteratorSymbol] = function () { return this.keys(); };
return Set;
}());
}
// naive WeakMap shim
function CreateWeakMapPolyfill() {
var UUID_SIZE = 16;
var keys = HashMap.create();
var rootKey = CreateUniqueKey();
return /** @class */ (function () {
function WeakMap() {
this._key = CreateUniqueKey();
}
WeakMap.prototype.has = function (target) {
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
return table !== undefined ? HashMap.has(table, this._key) : false;
};
WeakMap.prototype.get = function (target) {
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
return table !== undefined ? HashMap.get(table, this._key) : undefined;
};
WeakMap.prototype.set = function (target, value) {
var table = GetOrCreateWeakMapTable(target, /*create*/ true);
table[this._key] = value;
return this;
};
WeakMap.prototype.delete = function (target) {
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
return table !== undefined ? delete table[this._key] : false;
};
WeakMap.prototype.clear = function () {
// NOTE: not a real clear, just makes the previous data unreachable
this._key = CreateUniqueKey();
};
return WeakMap;
}());
function CreateUniqueKey() {
var key;
do
key = "@@WeakMap@@" + CreateUUID();
while (HashMap.has(keys, key));
keys[key] = true;
return key;
}
function GetOrCreateWeakMapTable(target, create) {
if (!hasOwn.call(target, rootKey)) {
if (!create)
return undefined;
Object.defineProperty(target, rootKey, { value: HashMap.create() });
}
return target[rootKey];
}
function FillRandomBytes(buffer, size) {
for (var i = 0; i < size; ++i)
buffer[i] = Math.random() * 0xff | 0;
return buffer;
}
function GenRandomBytes(size) {
if (typeof Uint8Array === "function") {
if (typeof crypto !== "undefined")
return crypto.getRandomValues(new Uint8Array(size));
if (typeof msCrypto !== "undefined")
return msCrypto.getRandomValues(new Uint8Array(size));
return FillRandomBytes(new Uint8Array(size), size);
}
return FillRandomBytes(new Array(size), size);
}
function CreateUUID() {
var data = GenRandomBytes(UUID_SIZE);
// mark as random - RFC 4122 § 4.4
data[6] = data[6] & 0x4f | 0x40;
data[8] = data[8] & 0xbf | 0x80;
var result = "";
for (var offset = 0; offset < UUID_SIZE; ++offset) {
var byte = data[offset];
if (offset === 4 || offset === 6 || offset === 8)
result += "-";
if (byte < 16)
result += "0";
result += byte.toString(16).toLowerCase();
}
return result;
}
}
// uses a heuristic used by v8 and chakra to force an object into dictionary mode.
function MakeDictionary(obj) {
obj.__ = undefined;
delete obj.__;
return obj;
}
});
})(Reflect || (Reflect = {}));
/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.App = void 0;
const utils_1 = __webpack_require__(3);
class App {
constructor() {
this.provides = [];
console.log("%c Anti-Redirect %c Copyright \xa9 2015-%s %s", 'font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size:64px;color:#00bbee;-webkit-text-fill-color:#00bbee;-webkit-text-stroke: 1px #00bbee;', "font-size:12px;color:#999999;", new Date().getFullYear(), "\n" + "Author @Axetroy");
console.log("[Anti Redirect]: 如果发现页面重定向未去除,欢迎反馈!");
console.log(`%c[Anti Redirect]: 支付宝搜索 "%c511118132%c" 领取红包支持作者!`, "font-size: 12px;", "font-size: 16px;color: red", "font-size: 12px;");
}
/**
* A 标签是否匹配服务提供者
* @param aElement
* @param provider
*/
isMatchProvider(aElement, provider) {
if (aElement.getAttribute(utils_1.Marker.RedirectStatusDone)) {
return false;
}
if (provider.test instanceof RegExp && !provider.test.test(aElement.href)) {
return false;
}
if (typeof provider.test === "function" && !provider.test(aElement)) {
return false;
}
if (provider.test instanceof Boolean) {
return provider.test;
}
return true;
}
/**
* 当鼠标移动到 A 标签上时
* @param event
*/
onHover(event) {
const aElement = event.target;
if (aElement.tagName !== "A") {
return;
}
// trigger on hover handler
for (const provider of this.provides) {
if (this.isMatchProvider(aElement, provider)) {
provider.resolve(aElement);
}
}
}
/**
* 当页面滚动时
*/
onScroll() {
// 筛选所有在可视区域内的A标签
const visibleElements = [].slice
.call(document.querySelectorAll("a[href]"))
.filter((aElement) => {
return (aElement.href.indexOf("http") > -1 &&
utils_1.isInView(aElement) &&
utils_1.getRedirect(aElement) <= 2);
});
// trigger scroll handler
for (const provider of this.provides) {
for (const aElement of visibleElements) {
if (this.isMatchProvider(aElement, provider)) {
provider.resolve(aElement);
}
}
}
}
/**
* 当页面准备就绪时,进行初始化动作
*/
pageOnReady() {
return __awaiter(this, void 0, void 0, function* () {
for (const provider of this.provides) {
if (provider.onInit) {
yield provider.onInit();
}
// 如果页面处于初始的状态,没有滚动过,则出发一次onScroll事件
if (window.scrollY <= 0) {
this.onScroll();
}
}
});
}
/**
* 设置配置
* @param config
*/
setConfig(config) {
this.config = config;
return this;
}
/**
* 注册服务提供者
* @param providers
*/
registerProvider(providers) {
for (const provideConfig of providers) {
// test 如果是 boolean
if (provideConfig.test === false) {
continue;
}
// test 如果是正则表达式
if (provideConfig.test instanceof RegExp &&
!provideConfig.test.test(document.domain)) {
continue;
}
// test 如果是一个function
if (typeof provideConfig.test === "function" &&
provideConfig.test() === false) {
continue;
}
const provider = new provideConfig.provider();
provider.isDebug = this.config.isDebug;
this.provides.push(provider);
console.info(`[Anti-redirect]: 加载引擎 ${provideConfig.name}`);
console.info(`当前页面: '${location.href}'`);
}
return this;
}
/**
* 启动应用
*/
bootstrap() {
addEventListener("scroll", this.onScroll.bind(this));
addEventListener("mousemove", this.onHover.bind(this));
addEventListener("DOMContentLoaded", this.pageOnReady.bind(this));
}
}
__decorate([
utils_1.throttleDecorator(50)
], App.prototype, "onHover", null);
__decorate([
utils_1.debounceDecorator(300)
], App.prototype, "onScroll", null);
exports.App = App;
/***/ }),
/* 3 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.antiRedirect = exports.decreaseRedirect = exports.increaseRedirect = exports.getRedirect = exports.isInView = exports.debounceDecorator = exports.throttleDecorator = exports.getText = exports.queryParser = exports.matchLinkFromUrl = exports.Marker = void 0;
const inView = __webpack_require__(4);
const debounce = __webpack_require__(5);
const throttle = __webpack_require__(6);
var Marker;
(function (Marker) {
Marker["RedirectCount"] = "redirect-count";
Marker["RedirectStatusDone"] = "anti-redirect-origin-href";
})(Marker = exports.Marker || (exports.Marker = {}));
/**
* 根据url上的路径匹配,去除重定向
* @param {HTMLAnchorElement} aElement
* @param {RegExp} tester
* @returns {boolean}
*/
function matchLinkFromUrl(aElement, tester) {
const matcher = tester.exec(aElement.href);
if (!matcher || !matcher.length || !matcher[1]) {
return "";
}
let url = "";
try {
url = decodeURIComponent(matcher[1]);
}
catch (e) {
url = /https?:\/\//.test(matcher[1]) ? matcher[1] : "";
}
return url;
}
exports.matchLinkFromUrl = matchLinkFromUrl;
class Query {
constructor(queryStr) {
this.queryStr = queryStr;
this.object = {};
this.object = this.toObject(queryStr.replace(/^\?+/, ""));
}
toObject(queryStr) {
const obj = {};
queryStr.split("&").forEach((item) => {
const arr = item.split("=") || [];
let key = arr[0] || "";
let value = arr[1] || "";
try {
key = decodeURIComponent(arr[0] || "");
value = decodeURIComponent(arr[1] || "");
}
catch (err) {
//
}
if (key) {
obj[key] = value;
}
});
return obj;
}
toString() {
const arr = [];
for (const key in this.object) {
if (this.object.hasOwnProperty(key)) {
const value = this.object[key];
arr.push(key + "=" + value);
}
}
return arr.length ? "?" + arr.join("&") : "";
}
}
function queryParser(queryString) {
return new Query(queryString);
}
exports.queryParser = queryParser;
function getText(htmlElement) {
return (htmlElement.innerText || htmlElement.textContent).trim();
}
exports.getText = getText;
function throttleDecorator(wait, options = {}) {
return (target, name, descriptor) => {
return {
configurable: true,
enumerable: descriptor.enumerable,
get() {
Object.defineProperty(this, name, {
configurable: true,
enumerable: descriptor.enumerable,
value: throttle(descriptor.value, wait, options),
});
return this[name];
},
};
};
}
exports.throttleDecorator = throttleDecorator;
function debounceDecorator(wait, options = {}) {
return (target, name, descriptor) => {
return {
configurable: true,
enumerable: descriptor.enumerable,
get() {
Object.defineProperty(this, name, {
configurable: true,
enumerable: descriptor.enumerable,
value: debounce(descriptor.value, wait, options),
});
return this[name];
},
};
};
}
exports.debounceDecorator = debounceDecorator;
function isInView(element) {
return inView.is(element);
}
exports.isInView = isInView;
function getRedirect(aElement) {
return +(aElement.getAttribute(Marker.RedirectCount) || 0);
}
exports.getRedirect = getRedirect;
function increaseRedirect(aElement) {
const num = getRedirect(aElement);
aElement.setAttribute(Marker.RedirectCount, num + 1 + "");
}
exports.increaseRedirect = increaseRedirect;
function decreaseRedirect(aElement) {
const num = getRedirect(aElement);
if (num > 0) {
aElement.setAttribute(Marker.RedirectCount, num - 1 + "");
}
}
exports.decreaseRedirect = decreaseRedirect;
/**
* 去除重定向
* @param aElement A标签元素
* @param realUrl 真实的地址
* @param options
*/
function antiRedirect(aElement, realUrl, options = {}) {
options.debug =
typeof options.debug === "undefined"
? "production" !== "production"
: options.debug;
options.force = options.force || false;
if (!options.force && (!realUrl || aElement.href === realUrl)) {
return;
}
if (options.debug) {
aElement.style.backgroundColor = "green";
}
aElement.setAttribute(Marker.RedirectStatusDone, aElement.href);
aElement.href = realUrl;
}
exports.antiRedirect = antiRedirect;
/***/ }),
/* 4 */
/***/ (function(module) {
/*!
* in-view 0.6.1 - Get notified when a DOM element enters or exits the viewport.
* Copyright (c) 2016 Cam Wiegert <[email protected]> - https://camwiegert.github.io/in-view
* License: MIT
*/
!function(t,e){ true?module.exports=e():0}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var i=n(2),o=r(i);t.exports=o["default"]},function(t,e){function n(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(9),o=r(i),u=n(3),f=r(u),s=n(4),c=function(){if("undefined"!=typeof window){var t=100,e=["scroll","resize","load"],n={history:[]},r={offset:{},threshold:0,test:s.inViewport},i=(0,o["default"])(function(){n.history.forEach(function(t){n[t].check()})},t);e.forEach(function(t){return addEventListener(t,i)}),window.MutationObserver&&addEventListener("DOMContentLoaded",function(){new MutationObserver(i).observe(document.body,{attributes:!0,childList:!0,subtree:!0})});var u=function(t){if("string"==typeof t){var e=[].slice.call(document.querySelectorAll(t));return n.history.indexOf(t)>-1?n[t].elements=e:(n[t]=(0,f["default"])(e,r),n.history.push(t)),n[t]}};return u.offset=function(t){if(void 0===t)return r.offset;var e=function(t){return"number"==typeof t};return["top","right","bottom","left"].forEach(e(t)?function(e){return r.offset[e]=t}:function(n){return e(t[n])?r.offset[n]=t[n]:null}),r.offset},u.threshold=function(t){return"number"==typeof t&&t>=0&&t<=1?r.threshold=t:r.threshold},u.test=function(t){return"function"==typeof t?r.test=t:r.test},u.is=function(t){return r.test(t,r)},u.offset(0),u}};e["default"]=c()},function(t,e){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(){function t(e,r){n(this,t),this.options=r,this.elements=e,this.current=[],this.handlers={enter:[],exit:[]},this.singles={enter:[],exit:[]}}return r(t,[{key:"check",value:function(){var t=this;return this.elements.forEach(function(e){var n=t.options.test(e,t.options),r=t.current.indexOf(e),i=r>-1,o=n&&!i,u=!n&&i;o&&(t.current.push(e),t.emit("enter",e)),u&&(t.current.splice(r,1),t.emit("exit",e))}),this}},{key:"on",value:function(t,e){return this.handlers[t].push(e),this}},{key:"once",value:function(t,e){return this.singles[t].unshift(e),this}},{key:"emit",value:function(t,e){for(;this.singles[t].length;)this.singles[t].pop()(e);for(var n=this.handlers[t].length;--n>-1;)this.handlers[t][n](e);return this}}]),t}();e["default"]=function(t,e){return new i(t,e)}},function(t,e){"use strict";function n(t,e){var n=t.getBoundingClientRect(),r=n.top,i=n.right,o=n.bottom,u=n.left,f=n.width,s=n.height,c={t:o,r:window.innerWidth-u,b:window.innerHeight-r,l:i},a={x:e.threshold*f,y:e.threshold*s};return c.t>e.offset.top+a.y&&c.r>e.offset.right+a.x&&c.b>e.offset.bottom+a.y&&c.l>e.offset.left+a.x}Object.defineProperty(e,"__esModule",{value:!0}),e.inViewport=n},function(t,e){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(e,function(){return this}())},function(t,e,n){var r=n(5),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){function r(t,e,n){function r(e){var n=x,r=m;return x=m=void 0,E=e,w=t.apply(r,n)}function a(t){return E=t,j=setTimeout(h,e),M?r(t):w}function l(t){var n=t-O,r=t-E,i=e-n;return _?c(i,g-r):i}function d(t){var n=t-O,r=t-E;return void 0===O||n>=e||n<0||_&&r>=g}function h(){var t=o();return d(t)?p(t):void(j=setTimeout(h,l(t)))}function p(t){return j=void 0,T&&x?r(t):(x=m=void 0,w)}function v(){void 0!==j&&clearTimeout(j),E=0,x=O=m=j=void 0}function y(){return void 0===j?w:p(o())}function b(){var t=o(),n=d(t);if(x=arguments,m=this,O=t,n){if(void 0===j)return a(O);if(_)return j=setTimeout(h,e),r(O)}return void 0===j&&(j=setTimeout(h,e)),w}var x,m,g,w,j,O,E=0,M=!1,_=!1,T=!0;if("function"!=typeof t)throw new TypeError(f);return e=u(e)||0,i(n)&&(M=!!n.leading,_="maxWait"in n,g=_?s(u(n.maxWait)||0,e):g,T="trailing"in n?!!n.trailing:T),b.cancel=v,b.flush=y,b}var i=n(1),o=n(8),u=n(10),f="Expected a function",s=Math.max,c=Math.min;t.exports=r},function(t,e,n){var r=n(6),i=function(){return r.Date.now()};t.exports=i},function(t,e,n){function r(t,e,n){var r=!0,f=!0;if("function"!=typeof t)throw new TypeError(u);return o(n)&&(r="leading"in n?!!n.leading:r,f="trailing"in n?!!n.trailing:f),i(t,e,{leading:r,maxWait:e,trailing:f})}var i=n(7),o=n(1),u="Expected a function";t.exports=r},function(t,e){function n(t){return t}t.exports=n}])});
/***/ }),
/* 5 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function() {
return root.Date.now();
};
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
result = wait - timeSinceLastCall;
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
}
/**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);
}
module.exports = debounce;
/***/ }),
/* 6 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function() {
return root.Date.now();
};
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
result = wait - timeSinceLastCall;
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/**
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. The throttled function comes with a `cancel`
* method to cancel delayed `func` invocations and a `flush` method to
* immediately invoke them. Provide `options` to indicate whether `func`
* should be invoked on the leading and/or trailing edge of the `wait`
* timeout. The `func` is invoked with the last arguments provided to the
* throttled function. Subsequent calls to the throttled function return the
* result of the last `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to throttle.
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=true]
* Specify invoking on the leading edge of the timeout.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new throttled function.
* @example
*
* // Avoid excessively updating the position while scrolling.
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
*
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
* jQuery(element).on('click', throttled);
*
* // Cancel the trailing throttled invocation.
* jQuery(window).on('popstate', throttled.cancel);
*/
function throttle(func, wait, options) {
var leading = true,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (isObject(options)) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
return debounce(func, wait, {
'leading': leading,
'maxWait': wait,
'trailing': trailing
});
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
}
/**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);
}
module.exports = throttle;
/***/ }),
/* 7 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RuyoProvider = void 0;
const utils_1 = __webpack_require__(3);
class RuyoProvider {
constructor() {
this.test = /\/[^\?]*\?u=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("u"));
}
}
exports.RuyoProvider = RuyoProvider;
/***/ }),
/* 8 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MozillaProvider = void 0;
const utils_1 = __webpack_require__(3);
class MozillaProvider {
constructor() {
this.test = /outgoing\.prod\.mozaws\.net\/v\d\/\w+\/(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, utils_1.matchLinkFromUrl(aElement, this.test));
}
}
exports.MozillaProvider = MozillaProvider;
/***/ }),
/* 9 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.YinXiangProvider = void 0;
const utils_1 = __webpack_require__(3);
class YinXiangProvider {
constructor() {
this.test = /^http:\/\//;
}
resolve(aElement) {
// 编辑器
if (aElement.hasAttribute("data-mce-href")) {
if (!aElement.onclick) {
utils_1.antiRedirect(aElement, aElement.href, { force: true });
aElement.onclick = (e) => {
// 阻止事件冒泡, 因为上层元素绑定的click事件会重定向
if (e.stopPropagation) {
e.stopPropagation();
}
aElement.setAttribute("target", "_blank");
window.top
? window.top.open(aElement.href)
: window.open(aElement.href);
};
}
}
// 分享页面
else if (/^https:\/\/app\.yinxiang\.com\/OutboundRedirect\.action\?dest=/.test(aElement.href)) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("dest"));
}
}
onInit() {
return __awaiter(this, void 0, void 0, function* () {
const handler = (e) => {
const dom = e.target;
const tagName = dom.tagName.toUpperCase();
switch (tagName) {
case "A":
this.resolve(dom);
break;
case "IFRAME":
if (dom.hasAttribute("anti-redirect-handled")) {
return;
}
dom.setAttribute("anti-redirect-handled", "1");
dom.contentWindow.document.addEventListener("mouseover", handler);
break;
}
};
document.addEventListener("mouseover", handler);
return this;
});
}
}
exports.YinXiangProvider = YinXiangProvider;
/***/ }),
/* 10 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CSDNProvider = void 0;
const utils_1 = __webpack_require__(3);
class CSDNProvider {
constructor() {
this.test = /^http:\/\//;
}
resolve(aElement) {
this.container = document.querySelector("#content_views");
if (this.container && this.container.contains(aElement)) {
if (!aElement.onclick) {
utils_1.antiRedirect(aElement, aElement.href, { force: true });
aElement.onclick = (e) => {
// 阻止事件冒泡, 因为上层元素绑定的click事件会重定向
if (e.stopPropagation) {
e.stopPropagation();
}
aElement.setAttribute("target", "_blank");
};
}
}
}
}
exports.CSDNProvider = CSDNProvider;
/***/ }),
/* 11 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ZhihuDailyProvider = void 0;
const utils_1 = __webpack_require__(3);
class ZhihuDailyProvider {
constructor() {
this.test = /zhihu\.com\/\?target=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
exports.ZhihuDailyProvider = ZhihuDailyProvider;
/***/ }),
/* 12 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GoogleDocsProvider = void 0;
const utils_1 = __webpack_require__(3);
class GoogleDocsProvider {
constructor() {
this.test = /www\.google\.com\/url\?q=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("q"));
}
}
exports.GoogleDocsProvider = GoogleDocsProvider;
/***/ }),
/* 13 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PocketProvider = void 0;
const utils_1 = __webpack_require__(3);
class PocketProvider {
constructor() {
this.test = /getpocket\.com\/redirect\?url=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("url"));
}
}
exports.PocketProvider = PocketProvider;
/***/ }),
/* 14 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GmailProvider = void 0;
const utils_1 = __webpack_require__(3);
class GmailProvider {
constructor() {
this.test = true;
this.REDIRECT_PROPERTY = "data-saferedirecturl";
}
resolve(aElement) {
// 移除这个属性,那么 a 链接就不会跳转
// FIXME: gmail 是多层 iframe 嵌套
if (aElement.getAttribute(this.REDIRECT_PROPERTY)) {
aElement.removeAttribute(this.REDIRECT_PROPERTY);
utils_1.antiRedirect(aElement, aElement.href);
}
}
}
exports.GmailProvider = GmailProvider;
/***/ }),
/* 15 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JuejinProvider = void 0;
const utils_1 = __webpack_require__(3);
class JuejinProvider {
constructor() {
this.test = /link\.juejin\.im\/\?target=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
exports.JuejinProvider = JuejinProvider;
/***/ }),
/* 16 */
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.QQMailProvider = void 0;
class QQMailProvider {
constructor() {
this.test = true;
}
resolve(aElement) {
this.container = document.querySelector("#contentDiv");
if (this.container && this.container.contains(aElement)) {
if (aElement.onclick) {
aElement.onclick = (e) => {
// 阻止事件冒泡, 因为上层元素绑定的click事件会重定向
if (e.stopPropagation) {
e.stopPropagation();
}
};
}
}
}
}
exports.QQMailProvider = QQMailProvider;
/***/ }),
/* 17 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MiJiProvider = void 0;
const utils_1 = __webpack_require__(3);
class MiJiProvider {
constructor() {
this.test = /mijisou\.com\/url_proxy\?proxyurl=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("proxyurl"));
}
}
exports.MiJiProvider = MiJiProvider;
/***/ }),
/* 18 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GooglePlayProvider = void 0;
const utils_1 = __webpack_require__(3);
class GooglePlayProvider {
test(aElement) {
if (/google\.com\/url\?q=(.*)/.test(aElement.href)) {
return true;
}
else if (/^\/store\/apps\/details/.test(location.pathname)) {
return true;
}
return false;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("q"));
// 移除开发者栏目下的重定向
const eles = [].slice.call(document.querySelectorAll("a.hrTbp"));
for (const ele of eles) {
if (!ele.href) {
continue;
}
if (ele.getAttribute(utils_1.Marker.RedirectStatusDone)) {
continue;
}
ele.setAttribute(utils_1.Marker.RedirectStatusDone, ele.href);
ele.setAttribute("target", "_blank");
ele.addEventListener("click", event => {
event.stopPropagation();
}, true);
}
}
}
exports.GooglePlayProvider = GooglePlayProvider;
/***/ }),
/* 19 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SteamProvider = void 0;
const utils_1 = __webpack_require__(3);
class SteamProvider {
constructor() {
this.test = /steamcommunity\.com\/linkfilter\/\?url=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get('url'));
}
}
exports.SteamProvider = SteamProvider;
/***/ }),
/* 20 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TiebaProvider = void 0;
const utils_1 = __webpack_require__(3);
class TiebaProvider {
constructor() {
this.test = /jump\d*\.bdimg\.com/;
}
resolve(aElement) {
if (!this.test.test(aElement.href)) {
return;
}
let url = "";
const text = aElement.innerText || aElement.textContent || "";
try {
if (/https?:\/\//.test(text)) {
url = decodeURIComponent(text);
}
}
catch (e) {
url = /https?:\/\//.test(text) ? text : "";
}
if (url) {
utils_1.antiRedirect(aElement, url);
}
}
}
exports.TiebaProvider = TiebaProvider;
/***/ }),
/* 21 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TwitterProvider = void 0;
const utils_1 = __webpack_require__(3);
class TwitterProvider {
constructor() {
this.test = /t\.co\/\w+/;
}
resolve(aElement) {
if (!this.test.test(aElement.href) ||
!/^https?:\/\//.test(aElement.title)) {
return;
}
const url = decodeURIComponent(aElement.title);
if (url) {
utils_1.antiRedirect(aElement, url);
}
}
}
exports.TwitterProvider = TwitterProvider;
/***/ }),
/* 22 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaiduVideoProvider = void 0;
const gm_http_1 = __webpack_require__(23);
const utils_1 = __webpack_require__(3);
class BaiduVideoProvider {
constructor() {
this.test = /v\.baidu\.com\/link\?url=/;
}
resolve(aElement) {
gm_http_1.default
.request({
url: aElement.href,
method: "GET",
anonymous: true
})
.then((res) => {
if (res.finalUrl) {
utils_1.antiRedirect(aElement, res.finalUrl);
}
})
.catch(err => {
console.error(err);
});
}
}
exports.BaiduVideoProvider = BaiduVideoProvider;
/***/ }),
/* 23 */
/***/ (function(module) {
(function webpackUniversalModuleDefinition(root, factory) {
if(true)
module.exports = factory();
else {}
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __nested_webpack_require_535__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_535__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __nested_webpack_require_535__.m = modules;
/******/
/******/ // expose the module cache
/******/ __nested_webpack_require_535__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __nested_webpack_require_535__.d = function(exports, name, getter) {
/******/ if(!__nested_webpack_require_535__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __nested_webpack_require_535__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __nested_webpack_require_535__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __nested_webpack_require_535__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __nested_webpack_require_535__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __nested_webpack_require_535__(__nested_webpack_require_535__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __nested_webpack_require_2812__) {
"use strict";
/**
* Created by axetroy on 17-6-23.
*/
/// <reference path="./index.d.ts" />
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
function isFunction(func) {
return typeof func === "function";
}
var Http = (function () {
function Http(config) {
if (config === void 0) { config = {}; }
this.config = config;
}
Http.prototype.setConfig = function (config) {
if (config === void 0) { config = {}; }
this.config = __assign({}, this.config, config);
};
Http.prototype.create = function (config) {
return new Http(config);
};
Http.prototype.request = function (config) {
var _this = this;
return new Promise(function (resolve, reject) {
var commonRequestConfig = {
method: config.method,
url: config.url,
data: config.body,
header: config.headers
};
var GM_xmlhttpRequestConfig = __assign({}, commonRequestConfig, config, _this.config);
var onreadystatechange = GM_xmlhttpRequestConfig.onreadystatechange, onerror = GM_xmlhttpRequestConfig.onerror, onabort = GM_xmlhttpRequestConfig.onabort, ontimeout = GM_xmlhttpRequestConfig.ontimeout;
GM_xmlhttpRequestConfig.synchronous = true; // async
GM_xmlhttpRequestConfig.onreadystatechange = function (response) {
try {
isFunction(onreadystatechange) &&
onreadystatechange.call(this, response);
}
catch (err) {
reject(err);
}
if (response.readyState !== 4)
return;
response.status >= 200 && response.status < 400
? resolve(response)
: reject(response);
};
GM_xmlhttpRequestConfig.onerror = function (response) {
try {
isFunction(onerror) && onerror.call(this, response);
reject(response);
}
catch (err) {
reject(err);
}
};
GM_xmlhttpRequestConfig.onabort = function (response) {
try {
isFunction(onabort) && onabort.call(this, response);
reject(response);
}
catch (err) {
reject(err);
}
};
GM_xmlhttpRequestConfig.ontimeout = function (response) {
try {
isFunction(ontimeout) && ontimeout.call(this, response);
reject(response);
}
catch (err) {
reject(err);
}
};
if (_this.config.debug) {
console.log("%c[" + commonRequestConfig.method.toUpperCase() + "]%c: " + commonRequestConfig.url, "color: green", "color: #000;text-style: under-line");
}
GM_xmlhttpRequest(__assign({}, GM_xmlhttpRequestConfig));
});
};
Http.prototype.get = function (url, data, headers, config) {
if (headers === void 0) { headers = {}; }
if (config === void 0) { config = {}; }
return this.request(__assign({ url: url, method: "GET", body: data, headers: headers }, config));
};
Http.prototype.post = function (url, data, headers, config) {
if (headers === void 0) { headers = {}; }
if (config === void 0) { config = {}; }
return this.request(__assign({ url: url, method: "POST", body: data, headers: headers }, config));
};
Http.prototype.put = function (url, data, headers, config) {
if (headers === void 0) { headers = {}; }
if (config === void 0) { config = {}; }
return this.request(__assign({ url: url, method: "POST", body: data, headers: headers }, config));
};
Http.prototype["delete"] = function (url, data, headers, config) {
if (headers === void 0) { headers = {}; }
if (config === void 0) { config = {}; }
return this.request(__assign({ url: url, method: "DELETE", body: data, headers: headers }, config));
};
Http.prototype.head = function (url, data, headers, config) {
if (headers === void 0) { headers = {}; }
if (config === void 0) { config = {}; }
return this.request(__assign({ url: url, method: "HEAD", body: data, headers: headers }, config));
};
return Http;
}());
exports.Http = Http;
var timeout = 5000;
exports.timeout = timeout;
var http = new Http({ timeout: timeout });
exports.http = http;
exports.default = http;
/***/ })
/******/ ]);
});
/***/ }),
/* 24 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WeboProvider = void 0;
const utils_1 = __webpack_require__(3);
class WeboProvider {
constructor() {
this.test = /t\.cn\/\w+/;
}
resolve(aElement) {
if (!this.test.test(aElement.href) ||
!/^https?:\/\//.test(aElement.title)) {
return;
}
const url = decodeURIComponent(aElement.title);
if (url) {
aElement.href = url;
utils_1.antiRedirect(aElement, url);
}
}
}
exports.WeboProvider = WeboProvider;
/***/ }),
/* 25 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaiduProvider = void 0;
const gm_http_1 = __webpack_require__(23);
const utils_1 = __webpack_require__(3);
class BaiduProvider {
constructor() {
this.test = /www\.baidu\.com\/link\?url=/;
}
resolve(aElement) {
if (utils_1.getRedirect(aElement) <= 2 && this.test.test(aElement.href)) {
utils_1.increaseRedirect(aElement);
this.handlerOneElement(aElement)
.then(res => {
utils_1.decreaseRedirect(aElement);
})
.catch(err => {
utils_1.decreaseRedirect(aElement);
});
}
}
handlerOneElement(aElement) {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield gm_http_1.default.request({
url: aElement.href,
method: "GET",
anonymous: true
});
if (res.finalUrl) {
utils_1.antiRedirect(aElement, res.finalUrl);
}
return res;
}
catch (err) {
console.error(err);
}
});
}
}
exports.BaiduProvider = BaiduProvider;
/***/ }),
/* 26 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DogeDogeProvider = void 0;
const gm_http_1 = __webpack_require__(23);
const utils_1 = __webpack_require__(3);
class DogeDogeProvider {
constructor() {
this.test = /www\.dogedoge\.com\/rd\/.{1,}/;
}
resolve(aElement) {
if (utils_1.getRedirect(aElement) <= 2 && this.test.test(aElement.href)) {
utils_1.increaseRedirect(aElement);
this.handlerOneElement(aElement)
.then(res => {
utils_1.decreaseRedirect(aElement);
})
.catch(err => {
utils_1.decreaseRedirect(aElement);
});
}
}
handlerOneElement(aElement) {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield gm_http_1.default.request({
url: aElement.href,
method: "GET",
anonymous: true
});
if (res.finalUrl) {
utils_1.antiRedirect(aElement, res.finalUrl);
}
return res;
}
catch (err) {
console.error(err);
}
});
}
}
exports.DogeDogeProvider = DogeDogeProvider;
/***/ }),
/* 27 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DouBanProvider = void 0;
const utils_1 = __webpack_require__(3);
class DouBanProvider {
constructor() {
this.test = /douban\.com\/link2\/?\?url=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("url"));
}
}
exports.DouBanProvider = DouBanProvider;
/***/ }),
/* 28 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GoogleProvider = void 0;
const utils_1 = __webpack_require__(3);
class GoogleProvider {
constructor() {
this.test = true;
}
resolve(aElement) {
// 移除追踪
if (aElement.getAttribute("ping")) {
aElement.removeAttribute("ping");
}
// 移除多余的事件
if (aElement.getAttribute("onmousedown")) {
aElement.removeAttribute("onmousedown");
}
// 尝试去除重定向
if (aElement.getAttribute("data-href")) {
const realUrl = aElement.getAttribute("data-href");
utils_1.antiRedirect(aElement, realUrl);
}
}
}
exports.GoogleProvider = GoogleProvider;
/***/ }),
/* 29 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JianShuProvider = void 0;
const utils_1 = __webpack_require__(3);
class JianShuProvider {
constructor() {
this.test = (aElement) => {
const isLink1 = /links\.jianshu\.com\/go/.test(aElement.href);
const isLink2 = /link\.jianshu\.com(\/)?\?t=/.test(aElement.href);
if (isLink1 || isLink2) {
return true;
}
return false;
};
}
resolve(aElement) {
const search = new URL(aElement.href).searchParams;
utils_1.antiRedirect(aElement, search.get('to') || search.get('t'));
}
}
exports.JianShuProvider = JianShuProvider;
/***/ }),
/* 30 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SoProvider = void 0;
const utils_1 = __webpack_require__(3);
class SoProvider {
constructor() {
this.test = /so\.com\/link\?(.*)/;
}
resolve(aElement) {
const url = aElement.getAttribute("data-mdurl") || aElement.getAttribute("e-landurl");
if (url) {
utils_1.antiRedirect(aElement, url);
}
// remove track
aElement.removeAttribute("e_href");
aElement.removeAttribute("data-res");
}
}
exports.SoProvider = SoProvider;
/***/ }),
/* 31 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SoGouProvider = void 0;
const gm_http_1 = __webpack_require__(23);
const utils_1 = __webpack_require__(3);
class SoGouProvider {
constructor() {
this.test = /www\.sogou\.com\/link\?url=/;
}
resolve(aElement) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (utils_1.getRedirect(aElement) <= 2 && this.test.test(aElement.href)) {
utils_1.increaseRedirect(aElement);
const res = yield gm_http_1.default.request({
url: aElement.href,
method: "GET",
anonymous: true
});
utils_1.decreaseRedirect(aElement);
const finalUrl = res.finalUrl;
if (finalUrl && !this.test.test(finalUrl)) {
utils_1.antiRedirect(aElement, res.finalUrl);
}
else {
const matcher = res.responseText.match(/URL=['"]([^'"]+)['"]/);
if (matcher && matcher[1]) {
utils_1.antiRedirect(aElement, res.finalUrl);
}
}
}
}
catch (err) {
utils_1.decreaseRedirect(aElement);
console.error(err);
}
});
}
parsePage(res) {
const responseText = res.responseText.replace(/(src=[^>]*|link=[^>])/g, "");
const html = document.createElement("html");
html.innerHTML = responseText;
// let selector = '#main .results div.vrwrap>h3';
// let selector = '#main .results h3>a';
const selector = '#main .results a[href*="www.sogou.com/link?url="]';
const remotes = [].slice.call(html.querySelectorAll("#main .results a[href]"));
const locals = [].slice.call(document.querySelectorAll(selector));
for (const localEle of locals) {
for (const remoteEle of remotes) {
let localText = utils_1.getText(localEle);
let remoteText = utils_1.getText(remoteEle);
// 通用按钮,例如【点击下载】
if (localEle.classList.contains("str-public-btn")) {
localText = utils_1.getText(localEle.parentNode);
remoteText = utils_1.getText(remoteEle.parentNode);
}
else if (localEle.classList.contains("str_img")) {
// 图片
localText = utils_1.getText(localEle.parentNode.parentNode);
remoteText = utils_1.getText(remoteEle.parentNode.parentNode);
}
if (!localText || localText !== remoteText) {
return;
}
utils_1.antiRedirect(localEle, remoteEle.href);
}
}
}
onInit() {
return __awaiter(this, void 0, void 0, function* () {
if (!/www\.sogou\.com\/web/.test(window.top.location.href)) {
return;
}
const query = utils_1.queryParser(window.top.location.search);
// 搜索使用http搜索,得到的是直接链接
const url = `${location.protocol
.replace(/:$/, "")
.replace("s", "")}://${location.host + location.pathname + query}`;
gm_http_1.default
.get(url)
.then((res) => {
this.parsePage(res);
})
.catch(err => {
console.error(err);
});
return this;
});
}
}
exports.SoGouProvider = SoGouProvider;
/***/ }),
/* 32 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.YoutubeProvider = void 0;
const utils_1 = __webpack_require__(3);
class YoutubeProvider {
constructor() {
this.test = /www\.youtube\.com\/redirect\?.{1,}/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("q"));
}
}
exports.YoutubeProvider = YoutubeProvider;
/***/ }),
/* 33 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ZhihuProvider = void 0;
const utils_1 = __webpack_require__(3);
class ZhihuProvider {
constructor() {
this.test = /zhihu\.com\/\?target=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
exports.ZhihuProvider = ZhihuProvider;
/***/ }),
/* 34 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaiduXueshuProvider = void 0;
const utils_1 = __webpack_require__(3);
class BaiduXueshuProvider {
constructor() {
this.test = /xueshu\.baidu\.com\/s?\?(.*)/; // 此处无用
}
resolve(aElement) {
const realHref = aElement.getAttribute("data-link") || aElement.getAttribute("data-url");
if (realHref) {
utils_1.antiRedirect(aElement, decodeURIComponent(realHref));
}
}
}
exports.BaiduXueshuProvider = BaiduXueshuProvider;
/***/ }),
/* 35 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ZhihuZhuanlanProvider = void 0;
const utils_1 = __webpack_require__(3);
class ZhihuZhuanlanProvider {
constructor() {
this.test = /link\.zhihu\.com\/\?target=(.*)/;
}
resolve(aElement) {
utils_1.antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
exports.ZhihuZhuanlanProvider = ZhihuZhuanlanProvider;
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].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].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/global */
/******/ (() => {
/******/ __webpack_require__.g = (function() {
/******/ if (typeof globalThis === 'object') return globalThis;
/******/ try {
/******/ return this || new Function('return this')();
/******/ } catch (e) {
/******/ if (typeof window === 'object') return window;
/******/ }
/******/ })();
/******/ })();
/******/
/************************************************************************/
/******/ // startup
/******/ // Load entry module
/******/ __webpack_require__(0);
/******/ // This entry module used 'exports' so it can't be inlined
/******/ })()
;