mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add onload hook
This commit is contained in:
parent
a556cb2045
commit
da64d2653d
@ -1,6 +1,6 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Bilibili Evolved (Offline)
|
// @name Bilibili Evolved (Offline)
|
||||||
// @version 250.89
|
// @version 251.27
|
||||||
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
|
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
|
||||||
// @author Grant Howard, Coulomb-G
|
// @author Grant Howard, Coulomb-G
|
||||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||||
@ -293,27 +293,32 @@ function setupAjaxHook()
|
|||||||
fireHandlers("after" + name, thisArgs, ...args);
|
fireHandlers("after" + name, thisArgs, ...args);
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
const hookOnEvent = (name, thisArg) =>
|
||||||
XMLHttpRequest.prototype.send = function (...args)
|
|
||||||
{
|
{
|
||||||
if (this.onreadystatechange)
|
if (thisArg[name])
|
||||||
{
|
{
|
||||||
const originalHandler = this.onreadystatechange;
|
const originalHandler = thisArg[name];
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
originalHandler.apply(this, args);
|
originalHandler.apply(thisArg, args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
||||||
|
XMLHttpRequest.prototype.send = function (...args)
|
||||||
|
{
|
||||||
|
hookOnEvent("onreadystatechange", this);
|
||||||
|
hookOnEvent("onload", this);
|
||||||
return hook("send", this, ...args);
|
return hook("send", this, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Bilibili Evolved (Preview Offline)
|
// @name Bilibili Evolved (Preview Offline)
|
||||||
// @version 250.89
|
// @version 251.27
|
||||||
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
|
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
|
||||||
// @author Grant Howard, Coulomb-G
|
// @author Grant Howard, Coulomb-G
|
||||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||||
@ -293,27 +293,32 @@ function setupAjaxHook()
|
|||||||
fireHandlers("after" + name, thisArgs, ...args);
|
fireHandlers("after" + name, thisArgs, ...args);
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
const hookOnEvent = (name, thisArg) =>
|
||||||
XMLHttpRequest.prototype.send = function (...args)
|
|
||||||
{
|
{
|
||||||
if (this.onreadystatechange)
|
if (thisArg[name])
|
||||||
{
|
{
|
||||||
const originalHandler = this.onreadystatechange;
|
const originalHandler = thisArg[name];
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
originalHandler.apply(this, args);
|
originalHandler.apply(thisArg, args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
||||||
|
XMLHttpRequest.prototype.send = function (...args)
|
||||||
|
{
|
||||||
|
hookOnEvent("onreadystatechange", this);
|
||||||
|
hookOnEvent("onload", this);
|
||||||
return hook("send", this, ...args);
|
return hook("send", this, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,27 +292,32 @@ function setupAjaxHook()
|
|||||||
fireHandlers("after" + name, thisArgs, ...args);
|
fireHandlers("after" + name, thisArgs, ...args);
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
const hookOnEvent = (name, thisArg) =>
|
||||||
XMLHttpRequest.prototype.send = function (...args)
|
|
||||||
{
|
{
|
||||||
if (this.onreadystatechange)
|
if (thisArg[name])
|
||||||
{
|
{
|
||||||
const originalHandler = this.onreadystatechange;
|
const originalHandler = thisArg[name];
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
originalHandler.apply(this, args);
|
originalHandler.apply(thisArg, args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
||||||
|
XMLHttpRequest.prototype.send = function (...args)
|
||||||
|
{
|
||||||
|
hookOnEvent("onreadystatechange", this);
|
||||||
|
hookOnEvent("onload", this);
|
||||||
return hook("send", this, ...args);
|
return hook("send", this, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,27 +292,32 @@ function setupAjaxHook()
|
|||||||
fireHandlers("after" + name, thisArgs, ...args);
|
fireHandlers("after" + name, thisArgs, ...args);
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
const hookOnEvent = (name, thisArg) =>
|
||||||
XMLHttpRequest.prototype.send = function (...args)
|
|
||||||
{
|
{
|
||||||
if (this.onreadystatechange)
|
if (thisArg[name])
|
||||||
{
|
{
|
||||||
const originalHandler = this.onreadystatechange;
|
const originalHandler = thisArg[name];
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
originalHandler.apply(this, args);
|
originalHandler.apply(thisArg, args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
||||||
|
XMLHttpRequest.prototype.send = function (...args)
|
||||||
|
{
|
||||||
|
hookOnEvent("onreadystatechange", this);
|
||||||
|
hookOnEvent("onload", this);
|
||||||
return hook("send", this, ...args);
|
return hook("send", this, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,27 +96,32 @@ export function setupAjaxHook()
|
|||||||
fireHandlers("after" + name, thisArgs, ...args);
|
fireHandlers("after" + name, thisArgs, ...args);
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
const hookOnEvent = (name, thisArg) =>
|
||||||
XMLHttpRequest.prototype.send = function (...args)
|
|
||||||
{
|
{
|
||||||
if (this.onreadystatechange)
|
if (thisArg[name])
|
||||||
{
|
{
|
||||||
const originalHandler = this.onreadystatechange;
|
const originalHandler = thisArg[name];
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
originalHandler.apply(this, args);
|
originalHandler.apply(thisArg, args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.onreadystatechange = (...args) =>
|
thisArg[name] = (...args) =>
|
||||||
{
|
{
|
||||||
fireHandlers("beforeOnReadyStateChange", this, ...args);
|
fireHandlers("before" + name, thisArg, ...args);
|
||||||
fireHandlers("afterOnReadyStateChange", this, ...args);
|
fireHandlers("after" + name, thisArg, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
XMLHttpRequest.prototype.open = function (...args) { return hook("open", this, ...args); };
|
||||||
|
XMLHttpRequest.prototype.send = function (...args)
|
||||||
|
{
|
||||||
|
hookOnEvent("onreadystatechange", this);
|
||||||
|
hookOnEvent("onload", this);
|
||||||
return hook("send", this, ...args);
|
return hook("send", this, ...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user