mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-16 10:10:20 +08:00
407 lines
42 KiB
JavaScript
407 lines
42 KiB
JavaScript
![]() |
/*******************************************************************************
|
||
|
|
||
|
uBlock Origin Lite - a comprehensive, MV3-compliant content blocker
|
||
|
Copyright (C) 2014-present Raymond Hill
|
||
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||
|
|
||
|
Home: https://github.com/gorhill/uBlock
|
||
|
|
||
|
*/
|
||
|
|
||
|
/* jshint esversion:11 */
|
||
|
/* global cloneInto */
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
// ruleset: default
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
// Important!
|
||
|
// Isolate from global scope
|
||
|
|
||
|
// Start of local scope
|
||
|
(( ) => {
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
// Start of code to inject
|
||
|
const uBOL_noWindowOpenIf = function() {
|
||
|
|
||
|
const scriptletGlobals = {}; // jshint ignore: line
|
||
|
|
||
|
const argsList = [[],["amazon-adsystem"],["|"],["","10"],["given"],["!bergblock","10"],["//"],["!za.gl","0"],["!?safelink_redirect="],["adblock","1","obj"],["!atomtt"],["!/download\\/|link/"],["!/^https:\\/\\/sendvid\\.com\\/[0-9a-z]+$/"],["/^/","1"],["!api?call=","10","obj"],["!/ytmp3|dropbox/"],["!gdrivedownload"],["!refine?search"],["!embedy"],["wapka"],["!t.me"],["!/prcf.fiyar|themes|pixsense|.jpg/"],["ppcnt"],["","1"],["!direct"],["/^/","15"],["_blank"],["?key="],["!koyso.com"],["!self"],["!blogspot"],["!vidhidepre.com"],["php"],["tempat.org"],["","5"],["!buzzheavier.com"],["onclickmega"],["!dosya","1"],["!newdmn","1"],["!/^\\/d\\//"],["!yt2api"],["!clickmp3"],["bitcoins-update.blogspot.com"],["!coinsearns.com"],["youtube"],["/^/","0"],["!ytcutter.net"],["!/d/"],["!download"],["/xlirdr|hotplay\\-games|hyenadata/"],["!/^\\//"],["/\\.(com|net)\\/4\\//"],["!shrdsk"],["!/^\\/download\\//"],["!abyss.to","1"],["!zuperdrive"]];
|
||
|
|
||
|
const hostnamesMap = new Map([["afreesms.com",0],["hltv.org",0],["mcloud.bz",0],["vidstream.pro",0],["dailyuploads.net",0],["putlocker-website.com",0],["filescdn.com",0],["deportealdia.live",0],["watchmyexgf.net",0],["upload-4ever.com",0],["vortez.net",0],["porn.com",0],["katestube.com",0],["mangoporn.net",0],["nwanime.tv",0],["chooyomi.com",0],["shooshtime.com",0],["picturelol.com",0],["imgspice.com",0],["pornhd.com",0],["bigtitsxxxsex.com",0],["vivud.com",0],["empflix.com",0],["anyporn.com",0],["magnetdl.com",0],["magnetdl.org",0],["short.pe",0],["donkparty.com",0],["dz4link.com",0],["tubemania.org",0],["webdesigndev.com",0],["imageweb.ws",0],["vidoza.net",0],["pelispop.net",0],["streampelis.club",0],["gamcore.com",0],["porcore.com",0],["69games.xxx",0],["vintage-erotica-forum.com",0],["momondo.com",0],["hentai2read.com",0],["lolhentai.net",0],["mangafreak.net",0],["itv.com",0],["hotscope.tv",0],["micloudfiles.com",0],["assia.tv",0],["assia4.com",0],["assia24.com",0],["seatguru.com",0],["asiananimaltube.org",0],["zoosex.pink",0],["pornrabbit.com",0],["cartoonporno.xxx",0],["youpornru.com",0],["hubfiles.ws",0],["uii.io",0],["powforums.com",0],["titsbox.com",0],["zmovs.com",0],["spycock.com",0],["cut-fly.com",0],["cine24.online",0],["xrivonet.info",0],["gounlimited.to",0],["shortit.pw",0],["pornve.com",0],["sawlive.tv",0],["veekyforums.com",0],["cutpaid.com",0],["televisionlibre.net",0],["durtypass.com",0],["opjav.com",0],["nhentai.net",0],["forexlap.com",0],["cambay.tv",0],["camwhoreshd.com",0],["camwhorespy.com",0],["cwtvembeds.com",0],["x08.ovh",0],["zegtrends.com",0],["fileone.tv",0],["mdbekjwqa.pw",0],["mdfx9dc8n.net",0],["mdzsmutpcvykb.net",0],["mixdrop21.net",0],["mixdropjmk.pw",0],["xpics.me",0],["milfzr.com",0],["pandamovies.pw",0],["simsdom.com",0],["cloudvideo.tv",0],["kinoger.ru",0],["xxxbunker.com",0],["clasicotas.org",0],["watchmoviesrulz.com",0],["sexgalaxy.net",0],["noticiasesports.live",0],["noweconomy.live",0],["googlvideo.com",0],["streamporn.pw",0],["zplayer.live",0],["faucethero.com",0],["720pxmovies.blogspot.com",0],["software-on.com",0],["cdna.tv",0],["cam4.com",0],["filerio.in",0],["ckk.ai",0],["shemalepower.xyz",0],["dlkoo.com",0],["bitcoinminingforex.blogspot.com",0],["vladan.fr",0],["losporn.org",0],["embedsito.com",0],["films5k.com",0],["javcl.me",0],["mavlecteur.com",0],["playfinder.xyz",0],["ujav.me",0],["tpxanime.in",0],["welovestream.xyz",0],["dreamfancy.org",0],["pornult.com",0],["nonktube.com",0],["tusfiles.com",0],["adultdvdparadise.com",0],["freeomovie.info",0],["fullxxxmovies.me",0],["mangoparody.com",0],["mangoporn.co",0],["netflixporno.net",0],["pandamovies.me",0],["playpornfree.xyz",0],["pornkino.cc",0],["pornwatch.ws",0],["watchfreexxx.pw",0],["watchxxxfree.pw",0],["xopenload.pw",0],["xtapes.me",0],["xxxmoviestream.xyz",0],["xxxparodyhd.net",0],["xxxscenes.net",0],["xxxstream.me",0],["youwatchporn.com",0],["skeimg.com",0],["4share.vn",0],["0xxx.ws",0],["ucptt.com",0],["exe.io",0],["exe.app",0],["skincarie.com",0],["fullhdxxx.com",0],["viptube.com",0],["homemature.net",0],["kingsofteens.com",0],["hentaihere.com",0],["yandexcdn.com",0],["iguarras.com",0],["peliculaspornomega.net",0],["adsafelink.com",0],["aii.sh",0],["czechvideo.org",0],["gfsvideos.com",0],["imagehaha.com",0],["vupload.com",0],["series-d.com",0],["naughtymachinima.com",0],["porn00.org",0],["savevideo.tube",0],["tr.savefrom.net",0],["xanimeporn.com",0],["bacakomik.co",0],["porngo.com",0],["streamplusvip.xyz",0],["playembed.xyz",0],["playtemporal.xyz",0],["dr-farfar.com",0],["yeswegays.com",0],["youramateurtube.com",0],["webtor.io",0],["luscious.net",0],["makemoneywithurl.com",0],["dflix.top",0],["gomo.to",0],["cryptofuns.ru",0],["animetemaefiore.club",0],["naniplay.com",0],["savesubs.com",0],["seriesynovelas.online",0],["interracial.com",0],["fatwhitebutt.com",0],["smplace.com",0],["slaughtergays.com",0],["sexiestpicture.com",0],["sassytube.com",0],["vipergirls.to",0],["xh.video",0],["lkc21.net",0],["freegogpcgames.com",0],["smiechawatv.pl",0],["tudogamesbr.com",0],["dogemate.com",0],["pstream.net",0],["shurt.pw",0]
|
||
|
|
||
|
const entitiesMap = new Map([["wcostream",0],["kissasian",0],["slreamplay",0],["steamplay",0],["steanplay",0],["stemplay",0],["streamp1ay",0],["streanplay",0],["streampiay",0],["stre4mplay",0],["vid2faf",0],["youtubedownloader",0],["plylive",0],["plyvdo",0],["putlockerc",0],["putlockertv",0],["mylink",0],["my1ink",0],["myl1nk",0],["myli3k",0],["pahe",0],["yts",0],["hqq",0],["waaw",0],["adshort",0],["adsrt",0],["tube8",0],["europixhd",0],["topeuropix",0],["watch-series",0],["watchseries",0],["gogoanime",0],["gogoanimes",0],["gogoanimetv",0],["imgdew",0],["imgmaze",0],["imgoutlet",0],["imgtown",0],["imgview",0],["dewimg",0],["imgrock",0],["imgviu",0],["mazpic",0],["outletpic",0],["picrok",0],["capshd",0],["rojadirectatvlive",0],["1movies",0],["jkanime",0],["xmovies8",0],["pelisplus",0],["pelisplushd",0],["pouvideo",0],["povvideo",0],["povvldeo",0],["povw1deo",0],["povwideo",0],["powv1deo",0],["powvibeo",0],["powvideo",0],["powvldeo",0],["arenavision",0],["ciberdvd",0],["pornfay",0],["camwhores",0],["camwhorestv",0],["redtube",0],["ettv",0],["ver-pelis",0],["newpelis",0],["pelix",0],["onlinevideoconverter",0],["adfloz",0],["movies123",0],["voirfilms",0],["vidcloud",0],["iframejav",0],["savemedia",0],["limetorrents",0],["telerium",0],["9xbuddy",0],["asianclub",0],["vidmoly",0],["savelinks",0],["mixdroop",0],["mixdrop",0],["mixdrp",0],["123moviesfree",0],["yesmovies",0],["solarmovie",0],["zeefiles",0],["mega4up",0],["bdiptv",0],["cinemalibero",0],["gomovies",0],["gomoviesc",0],["cloudvideotv",0],["123movierulz",0],["7movierulz1",0],["7moviesrulz",0],["5movierulz2",0],["movieruls",0],["movierulz",0],["movierulzfree",0],["movierulz2free",0],["movierulzs",0],["movierulzwatch",0],["movierulzz",0],["moviesrulz",0],["moviesrulzfree",0],["topflix",0],["allfeeds",0],["daddylive",0],["sporting77",0],["teleriumtv",0],["7starhd",0],["uploadev",0],["thefmovies",0],["keepvid",0],["ustream",0],["upvid",0],["ssrmovies",0],["moviflex",0],["fembed",0],["mavplay",0],["videobb",0],["123mkv",0],["pornhub",0],["megavideo",0],["pandamovie",0],["speedporn",0],["watchpornfree",0],["okanime",0],["spankbang",0],["linkshub",0],["tmearn",0],["filedown",0],["ffmovies",0],["beinmatch",0],["mrpiracy",0],["shorten",0],["123anime",0],["ytmp3",0],["gnula",0],["sobatkeren",0],["movieon21",0],["mkvcinemas",0],["pelispedia24",0],["pelis28",0],["remaxhd",0],["dood",0],["dooood",0],["nemenlake",0],["animeblix",0],["vidsrc",0],["binged",0],["fmovies",0],["kimcartoon",0],["torrentdownload",0],["file-upload",0],["embedme",0],["finfang",0],["hellnaw",0],["moonembed",0],["z12z0vla",0],["sharedrive",0],["dodz",0],["doodss",0],["doood",0],["doooood",0],["kakitengah",0],["zoro",0],["m4u",0],["xprime4u",0],["uhdmovies",0],["direct-dl",0],["filmy4web",0],["clk",0],["fc-lc",0],["hubdrive",0],["gosemut",0],["zone-annuaire",0],["notube",0],["uploadhub",0],["mm9844",0],["adblockeronstape",0],["adblockplustape",0],["adblockstreamtape",0],["adblockstrtape",0],["adblockstrtech",0],["antiadtape",0],["noblocktape",0],["shavetape",0],["stapadblockuser",0],["stape",0],["strcloud",0],["streamadblocker",0],["streamadblockplus",0],["streamta",0],["streamtape",0],["streamtapeadblock",0],["streamtapeadblockuser",0],["strtape",0],["strtapeadblock",0],["strtapeadblocker",0],["strtapewithadblock",0],["strtpe",0],["vidop",0],["seriemega",0],["isohunt",0],["megaflix",0],["drtuber",0],["ilgeniodellostreaming",0],["vid4up",0],["gototub",0],["sportbar",0],["youtubetomp3",0],["9xmovies",0],["shortzzy",0],["rojadirecta",0],["movidy",0],["downloadhub",0],["hubstream",0],["proxybit",0],["openloadmov",0],["wawacity",0],["dl-protect",0],["0gomovies",0],["player.msmini",0],["player.sbnmp",0],["netuplayer",0],["vapley",0],["moviehdf",0],["hd21",0],["iceporn",0],["nuvid",0],["pornlib",0],["tubeon",0],["vivatube",0],["winporn",0],["yeptube",0],["streamsport",0],["ytc",0],["shahid4u",0],["watchonlinemoviespk",0],["streamhub",0],["moviezwap",0],["javembed",0],["kissanime",0],["sexy-games",0],["todaypk",0],["todaypktv",0],["1todaypk",0],["usagoals",0],["uproxy",0],["oyohd",0],["720pstream",0],["inextmovies",0
|
||
|
|
||
|
const exceptionsMap = new Map([["notube.com",[0]]]);
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
function noWindowOpenIf(
|
||
|
pattern = '',
|
||
|
delay = '',
|
||
|
decoy = ''
|
||
|
) {
|
||
|
const safe = safeSelf();
|
||
|
const logPrefix = safe.makeLogPrefix('no-window-open-if', pattern, delay, decoy);
|
||
|
const targetMatchResult = pattern.startsWith('!') === false;
|
||
|
if ( targetMatchResult === false ) {
|
||
|
pattern = pattern.slice(1);
|
||
|
}
|
||
|
const rePattern = safe.patternToRegex(pattern);
|
||
|
let autoRemoveAfter = parseInt(delay);
|
||
|
if ( isNaN(autoRemoveAfter) ) {
|
||
|
autoRemoveAfter = -1;
|
||
|
}
|
||
|
const createDecoy = function(tag, urlProp, url) {
|
||
|
const decoyElem = document.createElement(tag);
|
||
|
decoyElem[urlProp] = url;
|
||
|
decoyElem.style.setProperty('height','1px', 'important');
|
||
|
decoyElem.style.setProperty('position','fixed', 'important');
|
||
|
decoyElem.style.setProperty('top','-1px', 'important');
|
||
|
decoyElem.style.setProperty('width','1px', 'important');
|
||
|
document.body.appendChild(decoyElem);
|
||
|
setTimeout(( ) => { decoyElem.remove(); }, autoRemoveAfter * 1000);
|
||
|
return decoyElem;
|
||
|
};
|
||
|
window.open = new Proxy(window.open, {
|
||
|
apply: function(target, thisArg, args) {
|
||
|
const haystack = args.join(' ');
|
||
|
if ( rePattern.test(haystack) !== targetMatchResult ) {
|
||
|
if ( safe.logLevel > 1 ) {
|
||
|
safe.uboLog(logPrefix, `Allowed (${args.join(', ')})`);
|
||
|
}
|
||
|
return Reflect.apply(target, thisArg, args);
|
||
|
}
|
||
|
safe.uboLog(logPrefix, `Prevented (${args.join(', ')})`);
|
||
|
if ( autoRemoveAfter < 0 ) { return null; }
|
||
|
const decoyElem = decoy === 'obj'
|
||
|
? createDecoy('object', 'data', ...args)
|
||
|
: createDecoy('iframe', 'src', ...args);
|
||
|
let popup = decoyElem.contentWindow;
|
||
|
if ( typeof popup === 'object' && popup !== null ) {
|
||
|
Object.defineProperty(popup, 'closed', { value: false });
|
||
|
} else {
|
||
|
const noopFunc = (function(){}).bind(self);
|
||
|
popup = new Proxy(self, {
|
||
|
get: function(target, prop) {
|
||
|
if ( prop === 'closed' ) { return false; }
|
||
|
const r = Reflect.get(...arguments);
|
||
|
if ( typeof r === 'function' ) { return noopFunc; }
|
||
|
return target[prop];
|
||
|
},
|
||
|
set: function() {
|
||
|
return Reflect.set(...arguments);
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
if ( safe.logLevel !== 0 ) {
|
||
|
popup = new Proxy(popup, {
|
||
|
get: function(target, prop) {
|
||
|
safe.uboLog(logPrefix, 'window.open / get', prop, '===', target[prop]);
|
||
|
return Reflect.get(...arguments);
|
||
|
},
|
||
|
set: function(target, prop, value) {
|
||
|
safe.uboLog(logPrefix, 'window.open / set', prop, '=', value);
|
||
|
return Reflect.set(...arguments);
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
return popup;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function safeSelf() {
|
||
|
if ( scriptletGlobals.safeSelf ) {
|
||
|
return scriptletGlobals.safeSelf;
|
||
|
}
|
||
|
const self = globalThis;
|
||
|
const safe = {
|
||
|
'Array_from': Array.from,
|
||
|
'Error': self.Error,
|
||
|
'Function_toStringFn': self.Function.prototype.toString,
|
||
|
'Function_toString': thisArg => safe.Function_toStringFn.call(thisArg),
|
||
|
'Math_floor': Math.floor,
|
||
|
'Math_max': Math.max,
|
||
|
'Math_min': Math.min,
|
||
|
'Math_random': Math.random,
|
||
|
'Object': Object,
|
||
|
'Object_defineProperty': Object.defineProperty.bind(Object),
|
||
|
'Object_defineProperties': Object.defineProperties.bind(Object),
|
||
|
'Object_fromEntries': Object.fromEntries.bind(Object),
|
||
|
'Object_getOwnPropertyDescriptor': Object.getOwnPropertyDescriptor.bind(Object),
|
||
|
'RegExp': self.RegExp,
|
||
|
'RegExp_test': self.RegExp.prototype.test,
|
||
|
'RegExp_exec': self.RegExp.prototype.exec,
|
||
|
'Request_clone': self.Request.prototype.clone,
|
||
|
'XMLHttpRequest': self.XMLHttpRequest,
|
||
|
'addEventListener': self.EventTarget.prototype.addEventListener,
|
||
|
'removeEventListener': self.EventTarget.prototype.removeEventListener,
|
||
|
'fetch': self.fetch,
|
||
|
'JSON': self.JSON,
|
||
|
'JSON_parseFn': self.JSON.parse,
|
||
|
'JSON_stringifyFn': self.JSON.stringify,
|
||
|
'JSON_parse': (...args) => safe.JSON_parseFn.call(safe.JSON, ...args),
|
||
|
'JSON_stringify': (...args) => safe.JSON_stringifyFn.call(safe.JSON, ...args),
|
||
|
'log': console.log.bind(console),
|
||
|
// Properties
|
||
|
logLevel: 0,
|
||
|
// Methods
|
||
|
makeLogPrefix(...args) {
|
||
|
return this.sendToLogger && `[${args.join(' \u205D ')}]` || '';
|
||
|
},
|
||
|
uboLog(...args) {
|
||
|
if ( this.sendToLogger === undefined ) { return; }
|
||
|
if ( args === undefined || args[0] === '' ) { return; }
|
||
|
return this.sendToLogger('info', ...args);
|
||
|
|
||
|
},
|
||
|
uboErr(...args) {
|
||
|
if ( this.sendToLogger === undefined ) { return; }
|
||
|
if ( args === undefined || args[0] === '' ) { return; }
|
||
|
return this.sendToLogger('error', ...args);
|
||
|
},
|
||
|
escapeRegexChars(s) {
|
||
|
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||
|
},
|
||
|
initPattern(pattern, options = {}) {
|
||
|
if ( pattern === '' ) {
|
||
|
return { matchAll: true };
|
||
|
}
|
||
|
const expect = (options.canNegate !== true || pattern.startsWith('!') === false);
|
||
|
if ( expect === false ) {
|
||
|
pattern = pattern.slice(1);
|
||
|
}
|
||
|
const match = /^\/(.+)\/([gimsu]*)$/.exec(pattern);
|
||
|
if ( match !== null ) {
|
||
|
return {
|
||
|
re: new this.RegExp(
|
||
|
match[1],
|
||
|
match[2] || options.flags
|
||
|
),
|
||
|
expect,
|
||
|
};
|
||
|
}
|
||
|
if ( options.flags !== undefined ) {
|
||
|
return {
|
||
|
re: new this.RegExp(this.escapeRegexChars(pattern),
|
||
|
options.flags
|
||
|
),
|
||
|
expect,
|
||
|
};
|
||
|
}
|
||
|
return { pattern, expect };
|
||
|
},
|
||
|
testPattern(details, haystack) {
|
||
|
if ( details.matchAll ) { return true; }
|
||
|
if ( details.re ) {
|
||
|
return this.RegExp_test.call(details.re, haystack) === details.expect;
|
||
|
}
|
||
|
return haystack.includes(details.pattern) === details.expect;
|
||
|
},
|
||
|
patternToRegex(pattern, flags = undefined, verbatim = false) {
|
||
|
if ( pattern === '' ) { return /^/; }
|
||
|
const match = /^\/(.+)\/([gimsu]*)$/.exec(pattern);
|
||
|
if ( match === null ) {
|
||
|
const reStr = this.escapeRegexChars(pattern);
|
||
|
return new RegExp(verbatim ? `^${reStr}$` : reStr, flags);
|
||
|
}
|
||
|
try {
|
||
|
return new RegExp(match[1], match[2] || undefined);
|
||
|
}
|
||
|
catch(ex) {
|
||
|
}
|
||
|
return /^/;
|
||
|
},
|
||
|
getExtraArgs(args, offset = 0) {
|
||
|
const entries = args.slice(offset).reduce((out, v, i, a) => {
|
||
|
if ( (i & 1) === 0 ) {
|
||
|
const rawValue = a[i+1];
|
||
|
const value = /^\d+$/.test(rawValue)
|
||
|
? parseInt(rawValue, 10)
|
||
|
: rawValue;
|
||
|
out.push([ a[i], value ]);
|
||
|
}
|
||
|
return out;
|
||
|
}, []);
|
||
|
return this.Object_fromEntries(entries);
|
||
|
},
|
||
|
onIdle(fn, options) {
|
||
|
if ( self.requestIdleCallback ) {
|
||
|
return self.requestIdleCallback(fn, options);
|
||
|
}
|
||
|
return self.requestAnimationFrame(fn);
|
||
|
},
|
||
|
};
|
||
|
scriptletGlobals.safeSelf = safe;
|
||
|
if ( scriptletGlobals.bcSecret === undefined ) { return safe; }
|
||
|
// This is executed only when the logger is opened
|
||
|
const bc = new self.BroadcastChannel(scriptletGlobals.bcSecret);
|
||
|
let bcBuffer = [];
|
||
|
safe.logLevel = scriptletGlobals.logLevel || 1;
|
||
|
safe.sendToLogger = (type, ...args) => {
|
||
|
if ( args.length === 0 ) { return; }
|
||
|
const text = `[${document.location.hostname || document.location.href}]${args.join(' ')}`;
|
||
|
if ( bcBuffer === undefined ) {
|
||
|
return bc.postMessage({ what: 'messageToLogger', type, text });
|
||
|
}
|
||
|
bcBuffer.push({ type, text });
|
||
|
};
|
||
|
bc.onmessage = ev => {
|
||
|
const msg = ev.data;
|
||
|
switch ( msg ) {
|
||
|
case 'iamready!':
|
||
|
if ( bcBuffer === undefined ) { break; }
|
||
|
bcBuffer.forEach(({ type, text }) =>
|
||
|
bc.postMessage({ what: 'messageToLogger', type, text })
|
||
|
);
|
||
|
bcBuffer = undefined;
|
||
|
break;
|
||
|
case 'setScriptletLogLevelToOne':
|
||
|
safe.logLevel = 1;
|
||
|
break;
|
||
|
case 'setScriptletLogLevelToTwo':
|
||
|
safe.logLevel = 2;
|
||
|
break;
|
||
|
}
|
||
|
};
|
||
|
bc.postMessage('areyouready?');
|
||
|
return safe;
|
||
|
}
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
const hnParts = [];
|
||
|
try { hnParts.push(...document.location.hostname.split('.')); }
|
||
|
catch(ex) { }
|
||
|
const hnpartslen = hnParts.length;
|
||
|
if ( hnpartslen === 0 ) { return; }
|
||
|
|
||
|
const todoIndices = new Set();
|
||
|
const tonotdoIndices = [];
|
||
|
|
||
|
// Exceptions
|
||
|
if ( exceptionsMap.size !== 0 ) {
|
||
|
for ( let i = 0; i < hnpartslen; i++ ) {
|
||
|
const hn = hnParts.slice(i).join('.');
|
||
|
const excepted = exceptionsMap.get(hn);
|
||
|
if ( excepted ) { tonotdoIndices.push(...excepted); }
|
||
|
}
|
||
|
exceptionsMap.clear();
|
||
|
}
|
||
|
|
||
|
// Hostname-based
|
||
|
if ( hostnamesMap.size !== 0 ) {
|
||
|
const collectArgIndices = hn => {
|
||
|
let argsIndices = hostnamesMap.get(hn);
|
||
|
if ( argsIndices === undefined ) { return; }
|
||
|
if ( typeof argsIndices === 'number' ) { argsIndices = [ argsIndices ]; }
|
||
|
for ( const argsIndex of argsIndices ) {
|
||
|
if ( tonotdoIndices.includes(argsIndex) ) { continue; }
|
||
|
todoIndices.add(argsIndex);
|
||
|
}
|
||
|
};
|
||
|
for ( let i = 0; i < hnpartslen; i++ ) {
|
||
|
const hn = hnParts.slice(i).join('.');
|
||
|
collectArgIndices(hn);
|
||
|
}
|
||
|
collectArgIndices('*');
|
||
|
hostnamesMap.clear();
|
||
|
}
|
||
|
|
||
|
// Entity-based
|
||
|
if ( entitiesMap.size !== 0 ) {
|
||
|
const n = hnpartslen - 1;
|
||
|
for ( let i = 0; i < n; i++ ) {
|
||
|
for ( let j = n; j > i; j-- ) {
|
||
|
const en = hnParts.slice(i,j).join('.');
|
||
|
let argsIndices = entitiesMap.get(en);
|
||
|
if ( argsIndices === undefined ) { continue; }
|
||
|
if ( typeof argsIndices === 'number' ) { argsIndices = [ argsIndices ]; }
|
||
|
for ( const argsIndex of argsIndices ) {
|
||
|
if ( tonotdoIndices.includes(argsIndex) ) { continue; }
|
||
|
todoIndices.add(argsIndex);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
entitiesMap.clear();
|
||
|
}
|
||
|
|
||
|
// Apply scriplets
|
||
|
for ( const i of todoIndices ) {
|
||
|
try { noWindowOpenIf(...argsList[i]); }
|
||
|
catch(ex) {}
|
||
|
}
|
||
|
argsList.length = 0;
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
};
|
||
|
// End of code to inject
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
// Inject code
|
||
|
|
||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1736575
|
||
|
// 'MAIN' world not yet supported in Firefox, so we inject the code into
|
||
|
// 'MAIN' ourself when environment in Firefox.
|
||
|
|
||
|
const targetWorld = 'MAIN';
|
||
|
|
||
|
// Not Firefox
|
||
|
if ( typeof wrappedJSObject !== 'object' || targetWorld === 'ISOLATED' ) {
|
||
|
return uBOL_noWindowOpenIf();
|
||
|
}
|
||
|
|
||
|
// Firefox
|
||
|
{
|
||
|
const page = self.wrappedJSObject;
|
||
|
let script, url;
|
||
|
try {
|
||
|
page.uBOL_noWindowOpenIf = cloneInto([
|
||
|
[ '(', uBOL_noWindowOpenIf.toString(), ')();' ],
|
||
|
{ type: 'text/javascript; charset=utf-8' },
|
||
|
], self);
|
||
|
const blob = new page.Blob(...page.uBOL_noWindowOpenIf);
|
||
|
url = page.URL.createObjectURL(blob);
|
||
|
const doc = page.document;
|
||
|
script = doc.createElement('script');
|
||
|
script.async = false;
|
||
|
script.src = url;
|
||
|
(doc.head || doc.documentElement || doc).append(script);
|
||
|
} catch (ex) {
|
||
|
console.error(ex);
|
||
|
}
|
||
|
if ( url ) {
|
||
|
if ( script ) { script.remove(); }
|
||
|
page.URL.revokeObjectURL(url);
|
||
|
}
|
||
|
delete page.uBOL_noWindowOpenIf;
|
||
|
}
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
// End of local scope
|
||
|
})();
|
||
|
|
||
|
/******************************************************************************/
|
||
|
|
||
|
void 0;
|