mirror of
https://github.com/titaniumnetwork-dev/Ultraviolet.git
synced 2025-05-16 21:10:02 -04:00
Almost done!
This commit is contained in:
parent
da5c0c88b1
commit
355e87dd21
13 changed files with 262 additions and 38 deletions
|
@ -1,14 +1,13 @@
|
|||
if (!self.__uv) {
|
||||
__uvHook(self, {
|
||||
prefix: '/sw/',
|
||||
encodeUrl: Ultraviolet.codec.xor.encode,
|
||||
decodeUrl: Ultraviolet.codec.xor.decode,
|
||||
}, '/bare/');
|
||||
__uvHook(self, self.__uv$config, self.__uv$config.bare);
|
||||
};
|
||||
|
||||
async function __uvHook(window, config = {}, bare = '/bare/') {
|
||||
if ('__uv' in window && window.__uv instanceof Ultraviolet) return false;
|
||||
|
||||
if (window.document && !!window.window) {
|
||||
window.document.querySelectorAll("script[__uv-script]").forEach(node => node.remove())
|
||||
};
|
||||
|
||||
const worker = !window.window;
|
||||
const master = '__uv';
|
||||
|
@ -42,6 +41,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
enumerable: false,
|
||||
});
|
||||
|
||||
|
||||
__uv.meta.origin = location.origin;
|
||||
__uv.location = client.location.emulate(
|
||||
(href) => {
|
||||
|
@ -146,6 +146,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
methodPrefix + 'storageObj',
|
||||
methodPrefix + 'url',
|
||||
methodPrefix + 'modifiedStyle',
|
||||
methodPrefix + 'config',
|
||||
'Ultraviolet',
|
||||
'__uvHook',
|
||||
];
|
||||
|
@ -403,7 +404,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
|
||||
if (__uv.attrs.isHtml(event.data.name)) {
|
||||
event.target.call(event.that, __uv.attributePrefix + '-attr-' + event.data.name, event.data.value);
|
||||
event.data.value = __uv.rewriteHtml(event.data.value, {...__uv.meta, document: true, injectHead: __uv.createHtmlInject(__uv.handlerScript, __uv.bundleScript, __uv.cookieStr, window.location.href) });
|
||||
event.data.value = __uv.rewriteHtml(event.data.value, {...__uv.meta, document: true, injectHead:__uv.createHtmlInject(__uv.handlerScript, __uv.bundleScript, __uv.configScript, __uv.cookieStr, window.location.href) });
|
||||
};
|
||||
|
||||
if (__uv.attrs.isSrcset(event.data.name)) {
|
||||
|
@ -522,7 +523,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
set: (target, that, [val]) => {
|
||||
target.call(that, __uv.rewriteHtml(val, {
|
||||
document: true,
|
||||
injectHead: __uv.createHtmlInject(__uv.handlerScript, __uv.bundleScript, __uv.cookieStr, window.location.href)
|
||||
injectHead: __uv.createHtmlInject(__uv.handlerScript, __uv.bundleScript, __uv.configScript, __uv.cookieStr, window.location.href)
|
||||
}))
|
||||
},
|
||||
});
|
||||
|
@ -585,7 +586,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
|
||||
if (__uv.attrs.isHtml(event.data.name)) {
|
||||
client.element.setAttribute.call(event.that.ownerElement, __uv.attributePrefix + '-attr-' + event.data.name, event.data.value);
|
||||
event.data.value = __uv.rewriteHtml(event.data.value, {...__uv.meta, document: true, injectHead: __uv.createHtmlInject(__uv.handlerScript, __uv.bundleScript, __uv.cookieStr, window.location.href) });
|
||||
event.data.value = __uv.rewriteHtml(event.data.value, {...__uv.meta, document: true, injectHead:__uv.createHtmlInject(__uv.handlerScript, __uv.bundleScript, __uv.configScript, __uv.cookieStr, window.location.href) });
|
||||
};
|
||||
|
||||
if (__uv.attrs.isSrcset(event.data.name)) {
|
||||
|
@ -599,8 +600,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
client.url.on('createObjectURL', event => {
|
||||
let url = event.target.call(event.that, event.data.object);
|
||||
if (url.startsWith('blob:' + location.origin)) {
|
||||
let newUrl = 'blob:' + __uv.meta.url.origin + url.slice('blob:'.length + location.origin.length);
|
||||
|
||||
let newUrl = 'blob:' + (__uv.meta.url.href !== 'about:blank' ? __uv.meta.url.origin : window.parent.__uv.meta.url.origin) + url.slice('blob:'.length + location.origin.length);
|
||||
__uv.blobUrls.set(newUrl, url);
|
||||
event.respondWith(newUrl);
|
||||
} else {
|
||||
|
@ -859,6 +859,20 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
);
|
||||
};
|
||||
|
||||
client.style.on('setCssText', event => {
|
||||
event.data.value = __uv.rewriteCSS(event.data.value, {
|
||||
context: 'declarationList',
|
||||
...__uv.meta
|
||||
});
|
||||
});
|
||||
|
||||
client.style.on('getCssText', event => {
|
||||
event.data.value = __uv.sourceCSS(event.data.value, {
|
||||
context: 'declarationList',
|
||||
...__uv.meta
|
||||
});
|
||||
});
|
||||
|
||||
// Hooking functions & descriptors
|
||||
client.fetch.overrideRequest();
|
||||
client.fetch.overrideUrl();
|
||||
|
@ -900,6 +914,7 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
client.workers.overrideImportScripts();
|
||||
client.workers.overridePostMessage();
|
||||
client.style.overrideSetGetProperty();
|
||||
client.style.overrideCssText();
|
||||
client.navigator.overrideSendBeacon();
|
||||
client.function.overrideFunction();
|
||||
client.function.overrideToString();
|
||||
|
@ -940,6 +955,12 @@ async function __uvHook(window, config = {}, bare = '/bare/') {
|
|||
__uv.$get = function(that) {
|
||||
if (that === window.location) return __uv.location;
|
||||
if (that === window.eval) return __uv.eval;
|
||||
if (that === window.parent) {
|
||||
return window.__uv$parent;
|
||||
};
|
||||
if (that === window.top) {
|
||||
return window.__uv$top;
|
||||
};
|
||||
return that;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue