diff --git a/1449696017588-comp.png b/1449696017588-comp.png new file mode 100644 index 0000000..1720dd2 Binary files /dev/null and b/1449696017588-comp.png differ diff --git a/build-chrome.js b/build-chrome.js index 9691c80..5e1dca9 100644 --- a/build-chrome.js +++ b/build-chrome.js @@ -23,8 +23,6 @@ const domains = [ "https://*.4chan.org/*", "https://*.4channel.org/*", "https://*.4plebs.org/*", - "https://*.pomf.cat/*", - "https://pomf.cat/*", "https://desuarchive.org/*", "https://archived.moe/*", "https://archive.nyafuu.org/*", @@ -34,69 +32,8 @@ const domains = [ "https://fireden.net/*", "https://thebarchive.com/*", "https://archiveofsins.com/*", - "https://catbox.moe/*", - "https://zz.ht/*", - "https://take-me-to.space/*", - "https://*.4cdn.org/*", - "https://*.desuarchive.org/*", - "https://*.archived.moe/*", - "https://*.archive.nyafuu.org/*", - "https://*.b4k.co/*", - "https://*.wakarimasen.moe/*", - "https://*.fireden.net/*", - "https://*.thebarchive.com/*", - "https://*.archiveofsins.com/*", - "https://*.catbox.moe/*", - "https://*.zz.ht/*", - "https://*.imouto.kawaii.su/*", - "https://*.take-me-to.space/*", - "https://*.gelbooru.com/*", - "https://*.yande.re/*", - "https://*.sankakucomplex.com/*", - "https://*.rule34.xxx/*", - "https://*.donmai.us/*", - "https://*.lolibooru.moe/*", - "https://*.allthefallen.moe/*", - "https://desu-usergeneratedcontent.xyz/*" ]; -const manif = { - "manifest_version": 2, -// "update_url": "https://github.com/coomdev/pngextraembedder/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/chrome_update.xml", - "name": "PngExtraEmbedder", - "description": "Discover embedded files on 4chan and archives!", - "version": "0." + rev, - "icons": { - "64": "1449696017588.png" - }, - "permissions": [ - "notifications", - "clipboardWrite", - "menus", - "activeTab", - "webRequest", - "webRequestBlocking", - "contextMenus", - ...domains - ], - "content_scripts": [ - { - "matches": domains, - "css": [], - "run_at": "document_start", - "js": ["dist/main.js"], - } - ], - "background": { - persistent: true, - "scripts": [ - "browser-polyfill.min.js", - "dist/background.js" - ] - } -}; - - const manif3 = { manifest_version: 3, // "update_url": "https://github.com/coomdev/pngextraembedder/raw/branch/%E4%B8%AD%E5%87%BA%E3%81%97/chrome_update.xml", @@ -107,14 +44,8 @@ const manif3 = { 64: "1449696017588.png" }, permissions: [ - //"notifications", - //"clipboardWrite", - //"activeTab", - "declarativeNetRequestWithHostAccess" - //"contextMenus", ], - host_permissions: domains, - //"host_permissions":[""], + "host_permissions":[""], web_accessible_resources: [{ resources: ["*.html", "*.js"], matches: [""] @@ -127,15 +58,15 @@ const manif3 = { js: ["dist/main.js"], } ], - declarative_net_request: { - rule_resources: [ - { - id: 'rule1', - enabled: true, - path: 'b4k-csp.json' - } - ] - } +// declarative_net_request: { +// rule_resources: [ +// { +// id: 'rule1', +// enabled: true, +// path: 'b4k-csp.json' +// } +// ] +// } }; (async () => { diff --git a/chrome/dist/background.js b/chrome/dist/background.js index cb1c99d..6b61b64 100644 --- a/chrome/dist/background.js +++ b/chrome/dist/background.js @@ -1874,6 +1874,8 @@ // src/platform.ts var lqueue = {}; + var localLoad = (key, def) => "__pee__" + key in localStorage ? JSON.parse(localStorage.getItem("__pee__" + key)) : def; + var localSet = (key, value) => localStorage.setItem("__pee__" + key, JSON.stringify(value)); var { port1, port2 } = new MessageChannel(); console.log("chrome_api", true); if (false) { @@ -1917,6 +1919,17 @@ for (const k of keys) ctor[k] = bridge(k, ctor[k]); }; + var popupport; + var pendingcmds = {}; + if (true) { + popupport = chrome.runtime.connect({ name: "popup" }); + popupport.onMessage.addListener((msg) => { + if (msg.id in pendingcmds) { + pendingcmds[msg.id](msg); + delete pendingcmds[msg.id]; + } + }); + } var Platform = class { static async openInTab(src, opts) { if (false) { @@ -1928,7 +1941,14 @@ i = (await obj2.tabs.getCurrent()).index + 1; return obj2.tabs.create({ active: opts.active, url: src, index: i }); } + static getValue(name, def) { + return localLoad(name, def); + } + static setValue(name, val) { + localSet(name, val); + } }; + Platform.cmdid = 0; Platform = __decorateClass([ Bridged ], Platform); diff --git a/chrome/dist/main.js b/chrome/dist/main.js index 7844dd0..93f988a 100644 --- a/chrome/dist/main.js +++ b/chrome/dist/main.js @@ -51,7 +51,7 @@ var define_BUILD_VERSION_default; var init_define_BUILD_VERSION = __esm({ ""() { - define_BUILD_VERSION_default = [0, 255]; + define_BUILD_VERSION_default = [0, 256]; } }); @@ -13819,50 +13819,7 @@ conc: 8, ho: false, blacklist: ["guro", "scat", "ryona", "gore"], - rsources: [ - { - name: "Gelbooru", - domain: "gelbooru.com", - endpoint: "/index.php?page=dapi&s=post&q=index&json=1&tags=md5:", - view: "https://gelbooru.com/index.php?page=post&s=view&id=" - }, - { - name: "Yandere", - domain: "yande.re", - endpoint: "/post.json?tags=md5:", - view: `https://yande.re/post/show/` - }, - { - name: "Sankaku", - domain: "capi-v2.sankakucomplex.com", - endpoint: "/posts/keyset?tags=md5:", - view: `https://chan.sankakucomplex.com/post/show/` - }, - { - name: "Rule34", - domain: "api.rule34.xxx", - endpoint: "/index.php?page=dapi&s=post&q=index&json=1&tags=md5:", - view: "https://rule34.xxx/index.php?page=post&s=view&id=" - }, - { - name: "Danbooru", - domain: "danbooru.donmai.us", - endpoint: "/posts.json?tags=md5:", - view: "https://danbooru.donmai.us/posts/" - }, - { - name: "Lolibooru", - domain: "lolibooru.moe", - endpoint: "/post.json?tags=md5:", - view: "https://lolibooru.moe/post/show/" - }, - { - name: "ATFbooru", - domain: "booru.allthefallen.moe", - endpoint: "/posts.json?tags=md5:", - view: "https://booru.allthefallen.moe/posts/" - } - ], + rsources: [], ...localLoad("settingsv2", {}) }); var settings = writable(initial_settings); @@ -14136,6 +14093,8 @@ // src/platform.ts var lqueue = {}; + var localLoad2 = (key, def) => "__pee__" + key in localStorage ? JSON.parse(localStorage.getItem("__pee__" + key)) : def; + var localSet2 = (key, value) => localStorage.setItem("__pee__" + key, JSON.stringify(value)); var { port1, port2 } = new MessageChannel(); console.log("chrome_api", false); if (true) { @@ -14179,10 +14138,33 @@ for (const k of keys) ctor[k] = bridge(k, ctor[k]); }; + var altdomains = [ + "desuarchive.org", + "archived.moe", + "archive.nyafuu.org", + "arch.b4k.co", + "archive.wakarimasen.moe", + "b4k.co", + "fireden.net", + "thebarchive.com", + "archiveofsins.com" + ]; function supportedAltDomain(s) { - if (false) - return GM.info.script.matches.slice(2).some((m) => m.includes(s)); - return !location.host.includes("boards.4chan"); + return altdomains.includes(s); + } + function supportedMainDomain(s) { + return ["boards.4channel.org", "boards.4chan.org"].includes(s); + } + var popupport; + var pendingcmds = {}; + if (true) { + popupport = chrome.runtime.connect({ name: "popup" }); + popupport.onMessage.addListener((msg) => { + if (msg.id in pendingcmds) { + pendingcmds[msg.id](msg); + delete pendingcmds[msg.id]; + } + }); } var Platform = class { static async openInTab(src, opts) { @@ -14195,10 +14177,35 @@ i = (await obj.tabs.getCurrent()).index + 1; return obj.tabs.create({ active: opts.active, url: src, index: i }); } + static getValue(name, def) { + return localLoad2(name, def); + } + static setValue(name, val) { + localSet2(name, val); + } }; + Platform.cmdid = 0; Platform = __decorateClass([ Bridged ], Platform); + var cmdid = 0; + function request(domain) { + try { + popupport.postMessage({ id: cmdid, type: "grant", domain }); + cmdid++; + } catch (e) { + if (e.message.includes("disconnected")) { + popupport = chrome.runtime.connect({ name: "popup" }); + popupport.onMessage.addListener((msg) => { + if (msg.id in pendingcmds) { + pendingcmds[msg.id](msg); + delete pendingcmds[msg.id]; + } + }); + return request(domain); + } + } + } async function serialize(src) { if (src instanceof FormData) { const value = []; @@ -19406,7 +19413,7 @@ // src/Components/App.svelte function add_css8(target) { - append_styles(target, "svelte-98wprd", '.bepis.svelte-98wprd.svelte-98wprd{max-height:260px;overflow-y:auto}.tagcont.svelte-98wprd.svelte-98wprd{display:flex;gap:5px;margin-bottom:10px;flex-wrap:wrap}label.svelte-98wprd>input[type="text"].svelte-98wprd,label.svelte-98wprd>input[type="number"].svelte-98wprd{width:95%}.content.svelte-98wprd.svelte-98wprd{display:flex;flex-direction:column}.error.svelte-98wprd.svelte-98wprd{color:red}hr.svelte-98wprd.svelte-98wprd{width:100%}h1.svelte-98wprd.svelte-98wprd{text-align:center}.form.svelte-98wprd.svelte-98wprd{display:flex;flex-direction:column;gap:20px;position:absolute;padding:15px;border:1px solid white;background-color:inherit;border-radius:10px}.form.svelte-98wprd>label.svelte-98wprd{display:flex;flex-direction:column;gap:10px}.newsbox.svelte-98wprd.svelte-98wprd{max-height:300px;overflow-y:scroll}.backpanel.svelte-98wprd.svelte-98wprd{position:absolute;right:32px;padding:10px;width:15%;top:32px;border:1px solid;border-radius:5px;background-color:rgba(0, 0, 0, 0.8);pointer-events:all;backdrop-filter:blur(9px);max-height:80vh;min-width:321px}'); + append_styles(target, "svelte-2r0xqp", '.bepis.svelte-2r0xqp.svelte-2r0xqp{max-height:260px;overflow-y:auto}.tagcont.svelte-2r0xqp.svelte-2r0xqp{display:flex;gap:5px;margin-bottom:10px;flex-wrap:wrap}label.svelte-2r0xqp>input[type="text"].svelte-2r0xqp,label.svelte-2r0xqp>input[type="number"].svelte-2r0xqp{width:95%}.content.svelte-2r0xqp.svelte-2r0xqp{display:flex;flex-direction:column}.error.svelte-2r0xqp.svelte-2r0xqp{color:red}hr.svelte-2r0xqp.svelte-2r0xqp{width:100%}h1.svelte-2r0xqp.svelte-2r0xqp{text-align:center}.form.svelte-2r0xqp.svelte-2r0xqp{display:flex;flex-direction:column;gap:20px;position:absolute;padding:15px;border:1px solid white;background-color:black;border-radius:10px}.form.svelte-2r0xqp>label.svelte-2r0xqp{display:flex;flex-direction:column;gap:10px}.newsbox.svelte-2r0xqp.svelte-2r0xqp{max-height:300px;overflow-y:scroll}.backpanel.svelte-2r0xqp.svelte-2r0xqp{position:absolute;right:32px;padding:10px;width:15%;top:32px;border:1px solid;border-radius:5px;background-color:rgba(0, 0, 0, 0.8);pointer-events:all;backdrop-filter:blur(9px);max-height:80vh;min-width:321px}'); } function get_each_context2(ctx, list, i) { const child_ctx = ctx.slice(); @@ -19465,10 +19472,10 @@ hr = element("hr"); t3 = space(); create_component(tabs.$$.fragment); - attr(h1, "class", "svelte-98wprd"); - attr(hr, "class", "svelte-98wprd"); - attr(div0, "class", "content svelte-98wprd"); - attr(div1, "class", "backpanel svelte-98wprd"); + attr(h1, "class", "svelte-2r0xqp"); + attr(hr, "class", "svelte-2r0xqp"); + attr(div0, "class", "content svelte-2r0xqp"); + attr(div1, "class", "backpanel svelte-2r0xqp"); }, m(target, anchor) { insert(target, div1, anchor); @@ -19593,7 +19600,7 @@ } }; } - function create_if_block_10(ctx) { + function create_if_block_11(ctx) { let tab; let current; tab = new Tab_default({ @@ -19685,7 +19692,7 @@ } }); tab4.$on("select", ctx[19]); - let if_block = ctx[8].akValid && create_if_block_10(ctx); + let if_block = ctx[8].akValid && create_if_block_11(ctx); return { c() { create_component(tab0.$$.fragment); @@ -19750,7 +19757,7 @@ transition_in(if_block, 1); } } else { - if_block = create_if_block_10(ctx2); + if_block = create_if_block_11(ctx2); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); @@ -19806,7 +19813,7 @@ } }; } - function create_if_block_9(ctx) { + function create_if_block_10(ctx) { let label; let input; let t; @@ -19842,7 +19849,7 @@ } }; } - function create_if_block_62(ctx) { + function create_if_block_72(ctx) { let t0; let label; let t1; @@ -19853,8 +19860,8 @@ let if_block1_anchor; let mounted; let dispose; - let if_block0 = ctx[8].herror && create_if_block_8(ctx); - let if_block1 = ctx[8].akValid && create_if_block_72(ctx); + let if_block0 = ctx[8].herror && create_if_block_9(ctx); + let if_block1 = ctx[8].akValid && create_if_block_8(ctx); return { c() { if (if_block0) @@ -19872,8 +19879,8 @@ if_block1_anchor = empty(); attr(a, "title", "Only requires Search Files permission. See Hydrus docs on where to set this up."); attr(input, "type", "text"); - attr(input, "class", "svelte-98wprd"); - attr(label, "class", "svelte-98wprd"); + attr(input, "class", "svelte-2r0xqp"); + attr(label, "class", "svelte-2r0xqp"); }, m(target, anchor) { if (if_block0) @@ -19899,7 +19906,7 @@ if (if_block0) { if_block0.p(ctx2, dirty); } else { - if_block0 = create_if_block_8(ctx2); + if_block0 = create_if_block_9(ctx2); if_block0.c(); if_block0.m(t0.parentNode, t0); } @@ -19914,7 +19921,7 @@ if (if_block1) { if_block1.p(ctx2, dirty); } else { - if_block1 = create_if_block_72(ctx2); + if_block1 = create_if_block_8(ctx2); if_block1.c(); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } @@ -19941,7 +19948,7 @@ } }; } - function create_if_block_8(ctx) { + function create_if_block_9(ctx) { let span; let t_value = ctx[8].herror + ""; let t; @@ -19949,7 +19956,7 @@ c() { span = element("span"); t = text(t_value); - attr(span, "class", "error svelte-98wprd"); + attr(span, "class", "error svelte-2r0xqp"); }, m(target, anchor) { insert(target, span, anchor); @@ -19965,7 +19972,7 @@ } }; } - function create_if_block_72(ctx) { + function create_if_block_8(ctx) { let label0; let t0; let input0; @@ -19986,12 +19993,12 @@ input1 = element("input"); set_style(input0, "width", "5ch"); attr(input0, "type", "number"); - attr(input0, "class", "svelte-98wprd"); - attr(label0, "class", "svelte-98wprd"); + attr(input0, "class", "svelte-2r0xqp"); + attr(label0, "class", "svelte-2r0xqp"); attr(input1, "placeholder", "Restrict to these tags (space to separate tags, _ to separate words)"); attr(input1, "type", "text"); - attr(input1, "class", "svelte-98wprd"); - attr(label1, "class", "svelte-98wprd"); + attr(input1, "class", "svelte-2r0xqp"); + attr(label1, "class", "svelte-2r0xqp"); }, m(target, anchor) { insert(target, label0, anchor); @@ -20097,8 +20104,8 @@ let if_block1_anchor; let mounted; let dispose; - let if_block0 = ctx[7].eye && create_if_block_9(ctx); - let if_block1 = ctx[7].hyd && create_if_block_62(ctx); + let if_block0 = ctx[7].eye && create_if_block_10(ctx); + let if_block1 = ctx[7].hyd && create_if_block_72(ctx); return { c() { label0 = element("label"); @@ -20319,7 +20326,7 @@ if (if_block0) { if_block0.p(ctx2, dirty); } else { - if_block0 = create_if_block_9(ctx2); + if_block0 = create_if_block_10(ctx2); if_block0.c(); if_block0.m(t16.parentNode, t16); } @@ -20352,7 +20359,7 @@ if (if_block1) { if_block1.p(ctx2, dirty); } else { - if_block1 = create_if_block_62(ctx2); + if_block1 = create_if_block_72(ctx2); if_block1.c(); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } @@ -20443,23 +20450,25 @@ let t2; let h30; let t4; - let div0; let t5; + let div0; + let t6; let button; - let t7; - let dialog; let t8; - let hr; + let dialog; let t9; + let hr; + let t10; let h31; - let t11; - let div1; let t12; + let div1; + let t13; let input1; let current; let mounted; let dispose; - let if_block = ctx[7].phash && create_if_block_52(ctx); + let if_block0 = ctx[7].phash && create_if_block_62(ctx); + let if_block1 = ctx[7].rsources.length == 0 && create_if_block_52(ctx); let each_value_4 = ctx[7].rsources; let each_blocks_1 = []; for (let i = 0; i < each_value_4.length; i += 1) { @@ -20488,37 +20497,40 @@ input0 = element("input"); t0 = text("\n Enable perceptual hash-based filtering"); t1 = space(); - if (if_block) - if_block.c(); + if (if_block0) + if_block0.c(); t2 = space(); h30 = element("h3"); h30.textContent = "Booru sources"; t4 = space(); + if (if_block1) + if_block1.c(); + t5 = space(); div0 = element("div"); for (let i = 0; i < each_blocks_1.length; i += 1) { each_blocks_1[i].c(); } - t5 = space(); + t6 = space(); button = element("button"); button.textContent = "Add a source"; - t7 = space(); - create_component(dialog.$$.fragment); t8 = space(); - hr = element("hr"); + create_component(dialog.$$.fragment); t9 = space(); + hr = element("hr"); + t10 = space(); h31 = element("h3"); h31.textContent = "Blacklisted tags"; - t11 = space(); + t12 = space(); div1 = element("div"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } - t12 = space(); + t13 = space(); input1 = element("input"); attr(input0, "type", "checkbox"); - attr(div0, "class", "tagcont svelte-98wprd"); - attr(hr, "class", "svelte-98wprd"); - attr(div1, "class", "tagcont svelte-98wprd"); + attr(div0, "class", "tagcont svelte-2r0xqp"); + attr(hr, "class", "svelte-2r0xqp"); + attr(div1, "class", "tagcont svelte-2r0xqp"); attr(input1, "placeholder", "Press enter after typing your tag"); }, m(target, anchor) { @@ -20527,29 +20539,32 @@ input0.checked = ctx[7].phash; append(label, t0); insert(target, t1, anchor); - if (if_block) - if_block.m(target, anchor); + if (if_block0) + if_block0.m(target, anchor); insert(target, t2, anchor); insert(target, h30, anchor); insert(target, t4, anchor); + if (if_block1) + if_block1.m(target, anchor); + insert(target, t5, anchor); insert(target, div0, anchor); for (let i = 0; i < each_blocks_1.length; i += 1) { each_blocks_1[i].m(div0, null); } - insert(target, t5, anchor); + insert(target, t6, anchor); insert(target, button, anchor); - insert(target, t7, anchor); - mount_component(dialog, target, anchor); insert(target, t8, anchor); - insert(target, hr, anchor); + mount_component(dialog, target, anchor); insert(target, t9, anchor); + insert(target, hr, anchor); + insert(target, t10, anchor); insert(target, h31, anchor); - insert(target, t11, anchor); + insert(target, t12, anchor); insert(target, div1, anchor); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(div1, null); } - insert(target, t12, anchor); + insert(target, t13, anchor); insert(target, input1, anchor); current = true; if (!mounted) { @@ -20566,16 +20581,27 @@ input0.checked = ctx2[7].phash; } if (ctx2[7].phash) { - if (if_block) { - if_block.p(ctx2, dirty); + if (if_block0) { + if_block0.p(ctx2, dirty); } else { - if_block = create_if_block_52(ctx2); - if_block.c(); - if_block.m(t2.parentNode, t2); + if_block0 = create_if_block_62(ctx2); + if_block0.c(); + if_block0.m(t2.parentNode, t2); } - } else if (if_block) { - if_block.d(1); - if_block = null; + } else if (if_block0) { + if_block0.d(1); + if_block0 = null; + } + if (ctx2[7].rsources.length == 0) { + if (if_block1) { + } else { + if_block1 = create_if_block_52(ctx2); + if_block1.c(); + if_block1.m(t5.parentNode, t5); + } + } else if (if_block1) { + if_block1.d(1); + if_block1 = null; } if (dirty[0] & 73856) { each_value_4 = ctx2[7].rsources; @@ -20654,40 +20680,44 @@ detach(label); if (detaching) detach(t1); - if (if_block) - if_block.d(detaching); + if (if_block0) + if_block0.d(detaching); if (detaching) detach(t2); if (detaching) detach(h30); if (detaching) detach(t4); + if (if_block1) + if_block1.d(detaching); + if (detaching) + detach(t5); if (detaching) detach(div0); destroy_each(each_blocks_1, detaching); if (detaching) - detach(t5); + detach(t6); if (detaching) detach(button); if (detaching) - detach(t7); + detach(t8); ctx[50](null); destroy_component(dialog, detaching); if (detaching) - detach(t8); + detach(t9); if (detaching) detach(hr); if (detaching) - detach(t9); + detach(t10); if (detaching) detach(h31); if (detaching) - detach(t11); + detach(t12); if (detaching) detach(div1); destroy_each(each_blocks, detaching); if (detaching) - detach(t12); + detach(t13); if (detaching) detach(input1); mounted = false; @@ -20695,7 +20725,7 @@ } }; } - function create_if_block_52(ctx) { + function create_if_block_62(ctx) { let label; let input; let t0; @@ -20710,9 +20740,9 @@ a = element("a"); a.textContent = "?"; attr(input, "type", "number"); - attr(input, "class", "svelte-98wprd"); + attr(input, "class", "svelte-2r0xqp"); attr(a, "title", "Higher will filter more potentially different images, lower will let more identical images through"); - attr(label, "class", "svelte-98wprd"); + attr(label, "class", "svelte-2r0xqp"); }, m(target, anchor) { insert(target, label, anchor); @@ -20738,6 +20768,22 @@ } }; } + function create_if_block_52(ctx) { + let p; + return { + c() { + p = element("p"); + p.textContent = "Don't know what to put here? Ask some anons ;)"; + }, + m(target, anchor) { + insert(target, p, anchor); + }, + d(detaching) { + if (detaching) + detach(p); + } + }; + } function create_each_block_4(ctx) { let tag; let current; @@ -20834,22 +20880,22 @@ button = element("button"); button.textContent = "Add"; attr(input0, "type", "text"); - attr(input0, "placeholder", "Gelbooru"); - attr(input0, "class", "svelte-98wprd"); - attr(label0, "class", "svelte-98wprd"); + attr(input0, "placeholder", "Safebooru"); + attr(input0, "class", "svelte-2r0xqp"); + attr(label0, "class", "svelte-2r0xqp"); attr(input1, "type", "text"); - attr(input1, "placeholder", "gelbooru.com"); - attr(input1, "class", "svelte-98wprd"); - attr(label1, "class", "svelte-98wprd"); + attr(input1, "placeholder", "safebooru.com"); + attr(input1, "class", "svelte-2r0xqp"); + attr(label1, "class", "svelte-2r0xqp"); attr(input2, "type", "text"); attr(input2, "placeholder", "/post.json?tags=md5:"); - attr(input2, "class", "svelte-98wprd"); - attr(label2, "class", "svelte-98wprd"); + attr(input2, "class", "svelte-2r0xqp"); + attr(label2, "class", "svelte-2r0xqp"); attr(input3, "type", "text"); - attr(input3, "placeholder", "https://yande.re/post/show/"); - attr(input3, "class", "svelte-98wprd"); - attr(label3, "class", "svelte-98wprd"); - attr(div, "class", "form svelte-98wprd"); + attr(input3, "placeholder", "https://safebooru.com/post/show/"); + attr(input3, "class", "svelte-2r0xqp"); + attr(label3, "class", "svelte-2r0xqp"); + attr(div, "class", "form svelte-2r0xqp"); }, m(target, anchor) { insert(target, div, anchor); @@ -21083,8 +21129,8 @@ if (ctx[7].fhost === void 0) add_render_callback(() => ctx[53].call(select)); attr(input, "type", "number"); - attr(input, "class", "svelte-98wprd"); - attr(label, "class", "svelte-98wprd"); + attr(input, "class", "svelte-2r0xqp"); + attr(label, "class", "svelte-2r0xqp"); }, m(target, anchor) { insert(target, p, anchor); @@ -21185,7 +21231,7 @@ for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } - attr(div, "class", "bepis svelte-98wprd"); + attr(div, "class", "bepis svelte-2r0xqp"); }, m(target, anchor) { insert(target, div, anchor); @@ -21473,7 +21519,7 @@ t2 = space(); div = element("div"); if_block.c(); - attr(div, "class", "newsbox svelte-98wprd"); + attr(div, "class", "newsbox svelte-2r0xqp"); }, m(target, anchor) { insert(target, p, anchor); @@ -21819,6 +21865,10 @@ $$invalidate(3, news = await res.json()); }; function appendBooru() { + if (true) { + request(newbooru.domain); + alert("Requested! Please click the PEE icon to validate"); + } set_store_value(settings, $settings.rsources = [...$settings.rsources, newbooru], $settings); dial.toggle(); $$invalidate(1, newbooru = {}); @@ -24747,6 +24797,8 @@ var ViewCount_default = ViewCount; // src/main.ts + if (!supportedMainDomain(location.host) && !supportedAltDomain(location.host)) + throw "PEE not supported here, skipping"; var qp; var csettings5 = initial_settings; var processors = [thirdeye_default, pomf_default, pngv3_default, jpg_default, webm_default, gif_default]; @@ -24998,14 +25050,21 @@ var __DOMParser = false ? _DOMParser : DOMParser; var gmo; var earlystartup = async () => { - if (location.host == "arch.b4k.co" && false) { + if (["arch.b4k.co", "desuarchive.org"].includes(location.host) && false) { if (!GM_getValue("warning_seen2", false)) { - alert(`Due to b4k's policies being mean, PEE will get you banned, so the userscript version is disabled here`); - alert("Use the WebExtension version of PEE if you want to use b4k!"); + alert(`Due to b4k and desuarchive policies being mean, PEE will get you banned, so the userscript version is disabled here +Use the WebExtension version of PEE if you want to use b4k!`); GM_setValue("warning_seen2", true); return false; } } + if (["arch.b4k.co", "desuarchive.org"].includes(location.host) && true) { + if (!Platform.getValue("warning_seen3", false)) { + alert('Due to b4k and desuarchive policies being mean, PEE cannot display content properly here. A "PEE companion" extension will be released as including that functionnallity in PEE lengthens ChromeWebStore review delays, please understando.'); + Platform.setValue("warning_seen3", true); + return false; + } + } return true; }; var init4 = false; diff --git a/chrome/manifest.json b/chrome/manifest.json index 1b01aec..be1e59f 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -2,53 +2,13 @@ "manifest_version": 3, "name": "PngExtraEmbedder", "description": "Discover embedded files on 4chan and archives!", - "version": "0.255", + "version": "0.256", "icons": { "64": "1449696017588.png" }, - "permissions": [ - "declarativeNetRequestWithHostAccess" - ], + "permissions": [], "host_permissions": [ - "https://*.coom.tech/*", - "https://*.4chan.org/*", - "https://*.4channel.org/*", - "https://*.4plebs.org/*", - "https://*.pomf.cat/*", - "https://pomf.cat/*", - "https://desuarchive.org/*", - "https://archived.moe/*", - "https://archive.nyafuu.org/*", - "https://arch.b4k.co/*", - "https://archive.wakarimasen.moe/*", - "https://b4k.co/*", - "https://fireden.net/*", - "https://thebarchive.com/*", - "https://archiveofsins.com/*", - "https://catbox.moe/*", - "https://zz.ht/*", - "https://take-me-to.space/*", - "https://*.4cdn.org/*", - "https://*.desuarchive.org/*", - "https://*.archived.moe/*", - "https://*.archive.nyafuu.org/*", - "https://*.b4k.co/*", - "https://*.wakarimasen.moe/*", - "https://*.fireden.net/*", - "https://*.thebarchive.com/*", - "https://*.archiveofsins.com/*", - "https://*.catbox.moe/*", - "https://*.zz.ht/*", - "https://*.imouto.kawaii.su/*", - "https://*.take-me-to.space/*", - "https://*.gelbooru.com/*", - "https://*.yande.re/*", - "https://*.sankakucomplex.com/*", - "https://*.rule34.xxx/*", - "https://*.donmai.us/*", - "https://*.lolibooru.moe/*", - "https://*.allthefallen.moe/*", - "https://desu-usergeneratedcontent.xyz/*" + "" ], "web_accessible_resources": [ { @@ -68,8 +28,6 @@ "https://*.4chan.org/*", "https://*.4channel.org/*", "https://*.4plebs.org/*", - "https://*.pomf.cat/*", - "https://pomf.cat/*", "https://desuarchive.org/*", "https://archived.moe/*", "https://archive.nyafuu.org/*", @@ -78,31 +36,7 @@ "https://b4k.co/*", "https://fireden.net/*", "https://thebarchive.com/*", - "https://archiveofsins.com/*", - "https://catbox.moe/*", - "https://zz.ht/*", - "https://take-me-to.space/*", - "https://*.4cdn.org/*", - "https://*.desuarchive.org/*", - "https://*.archived.moe/*", - "https://*.archive.nyafuu.org/*", - "https://*.b4k.co/*", - "https://*.wakarimasen.moe/*", - "https://*.fireden.net/*", - "https://*.thebarchive.com/*", - "https://*.archiveofsins.com/*", - "https://*.catbox.moe/*", - "https://*.zz.ht/*", - "https://*.imouto.kawaii.su/*", - "https://*.take-me-to.space/*", - "https://*.gelbooru.com/*", - "https://*.yande.re/*", - "https://*.sankakucomplex.com/*", - "https://*.rule34.xxx/*", - "https://*.donmai.us/*", - "https://*.lolibooru.moe/*", - "https://*.allthefallen.moe/*", - "https://desu-usergeneratedcontent.xyz/*" + "https://archiveofsins.com/*" ], "css": [], "run_at": "document_start", @@ -110,14 +44,5 @@ "dist/main.js" ] } - ], - "declarative_net_request": { - "rule_resources": [ - { - "id": "rule1", - "enabled": true, - "path": "b4k-csp.json" - } - ] - } + ] } \ No newline at end of file diff --git a/chrome/options.js b/chrome/options.js deleted file mode 100644 index fb9342f..0000000 --- a/chrome/options.js +++ /dev/null @@ -1,3 +0,0 @@ -console.log('optiosn') -debugger; -console.log('optiosn') diff --git a/pee-companion/144.png b/pee-companion/144.png new file mode 100644 index 0000000..dc6a7b2 Binary files /dev/null and b/pee-companion/144.png differ diff --git a/pee-companion/1449696017588-comp.png b/pee-companion/1449696017588-comp.png new file mode 100644 index 0000000..1720dd2 Binary files /dev/null and b/pee-companion/1449696017588-comp.png differ diff --git a/chrome/_metadata/generated_indexed_rulesets/_ruleset1 b/pee-companion/_metadata/generated_indexed_rulesets/_ruleset1 similarity index 100% rename from chrome/_metadata/generated_indexed_rulesets/_ruleset1 rename to pee-companion/_metadata/generated_indexed_rulesets/_ruleset1 diff --git a/pee-companion/b4k-csp.json b/pee-companion/b4k-csp.json new file mode 100644 index 0000000..69b191d --- /dev/null +++ b/pee-companion/b4k-csp.json @@ -0,0 +1,21 @@ +[{ + "id": 1, + "priority": 1, + "action": { + "type": "modifyHeaders", + "responseHeaders": [ + { + "header": "content-security-policy", + "operation": "remove" + } + ] + }, + "condition": { + "requestDomains": [ + "arch.b4k.co", "desuarchive.org" + ], + "resourceTypes": [ + "main_frame" + ] + } +}] diff --git a/pee-companion/manifest.json b/pee-companion/manifest.json new file mode 100644 index 0000000..bb76bc6 --- /dev/null +++ b/pee-companion/manifest.json @@ -0,0 +1,25 @@ +{ + "manifest_version": 3, + "name": "PEE Companion", + "description": "Bypass content blocking on mean archives!", + "version": "1.0", + "icons": { + "64": "1449696017588-comp.png" + }, + "permissions": [ + "declarativeNetRequestWithHostAccess" + ], + "host_permissions": [ + "https://desuarchive.org/*", + "https://arch.b4k.co/*" + ], + "declarative_net_request": { + "rule_resources": [ + { + "id": "rule1", + "enabled": true, + "path": "b4k-csp.json" + } + ] + } +} \ No newline at end of file diff --git a/src/Components/App.svelte b/src/Components/App.svelte index e3e39d8..b615225 100644 --- a/src/Components/App.svelte +++ b/src/Components/App.svelte @@ -14,7 +14,7 @@ import { settings, appState } from "../stores"; import { filehosts } from "../filehosts"; import HydrusSearch from "./HydrusSearch.svelte"; - import { ifetch } from "../platform"; + import { request, ifetch } from "../platform"; import { writable } from "svelte/store"; let newbooru: Partial & { view: string }> = {}; @@ -32,6 +32,11 @@ }; function appendBooru() { + if (execution_mode != "userscript") { + request(newbooru.domain!); + alert("Requested! Please click the PEE icon to validate"); + } + $settings.rsources = [...$settings.rsources, newbooru as any]; dial.toggle(); newbooru = {}; @@ -246,6 +251,9 @@ {/if}

Booru sources

+ {#if $settings.rsources.length == 0} +

Don't know what to put here? Ask some anons ;)

+ {/if}
{#each $settings.rsources as source, i} @@ -279,7 +287,7 @@ Domain @@ -295,7 +303,7 @@ Post page prefix (for sources) @@ -433,7 +441,7 @@ position: absolute; padding: 15px; border: 1px solid white; - background-color: inherit; + background-color: black; border-radius: 10px; } diff --git a/src/main.ts b/src/main.ts index 91452c7..8dd48a3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,12 +20,15 @@ import NotificationsHandler from './Components/NotificationsHandler.svelte'; import { decodeCoom3Payload, fireNotification, getEmbedsFromCache, getSelectedFile } from "./utils"; import { getQueryProcessor, QueryProcessor } from "./websites"; -import { ifetch, Platform, streamRemote, supportedAltDomain } from "./platform"; +import { ifetch, Platform, streamRemote, supportedAltDomain, supportedMainDomain } from "./platform"; import TextEmbeddingsSvelte from "./Components/TextEmbeddings.svelte"; import { HydrusClient } from "./hydrus"; import { registerPlugin } from 'linkifyjs'; import ViewCountSvelte from "./Components/ViewCount.svelte"; +if (!supportedMainDomain(location.host) && !supportedAltDomain(location.host)) + throw "PEE not supported here, skipping"; + export interface ImageProcessor { skip?: true; match(fn: string): boolean; @@ -403,14 +406,20 @@ const cleanupHTML = (ndom: Document) => { let gmo: MutationObserver; const earlystartup = async () => { - if (location.host == 'arch.b4k.co' && execution_mode == "userscript") { + if (['arch.b4k.co', 'desuarchive.org'].includes(location.host) && execution_mode == "userscript") { if (!GM_getValue("warning_seen2", false)) { - alert(`Due to b4k's policies being mean, PEE will get you banned, so the userscript version is disabled here`); - alert("Use the WebExtension version of PEE if you want to use b4k!"); // "Cool new features will be coming to it, too", then MV3 happened. + alert(`Due to b4k and desuarchive policies being mean, PEE will get you banned, so the userscript version is disabled here\n` + "Use the WebExtension version of PEE if you want to use b4k!"); // "Cool new features will be coming to it, too", then MV3 happened. GM_setValue("warning_seen2", true); return false; } } + if (['arch.b4k.co', 'desuarchive.org'].includes(location.host) && execution_mode == "chrome_api") { + if (!Platform.getValue("warning_seen3", false)) { + alert("Due to b4k and desuarchive policies being mean, PEE cannot display content properly here. A \"PEE companion\" extension will be released as including that functionnallity in PEE lengthens ChromeWebStore review delays, please understando."); + Platform.setValue("warning_seen3", true); + return false; + } + } return true; }; @@ -536,7 +545,7 @@ const startup = async (is4chanX = true) => { } const appHost = textToElement(`
`); - const appInstance = new App({ target: appHost, props: {rev: BUILD_VERSION[1]} }); + const appInstance = new App({ target: appHost, props: { rev: BUILD_VERSION[1] } }); document.body.append(appHost); const scrollHost = textToElement(`
`); diff --git a/src/platform.ts b/src/platform.ts index 4b64982..f875e2c 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -2,6 +2,14 @@ import { GM_fetch, GM_head, headerStringToObject } from './requests'; const lqueue = {} as any; +const localLoad = (key: string, def: T) => + ('__pee__' + key) in localStorage + ? JSON.parse(localStorage.getItem('__pee__' + key)!) as T + : def; + +const localSet = (key: string, value: any) => + localStorage.setItem('__pee__' + key, JSON.stringify(value)); + const { port1, port2 } = new MessageChannel(); console.log(execution_mode, isBackground); if (execution_mode != 'userscript' && !isBackground) { @@ -62,15 +70,44 @@ const Bridged = (ctor: any) => { ctor[k] = bridge(k, ctor[k]); }; +const altdomains = [ + "desuarchive.org", + "archived.moe", + "archive.nyafuu.org", + "arch.b4k.co", + "archive.wakarimasen.moe", + "b4k.co", + "fireden.net", + "thebarchive.com", + "archiveofsins.com", +]; + export function supportedAltDomain(s: string) { - if (execution_mode == 'userscript') - return GM.info.script.matches.slice(2).some(m => m.includes(s)); - return !location.host.includes('boards.4chan'); + return altdomains.includes(s); +} + +export function supportedMainDomain(s: string) { + return ['boards.4channel.org', 'boards.4chan.org'].includes(s); } +let popupport: browser.runtime.Port; + +const pendingcmds: Record void> = {}; + +if (execution_mode == "chrome_api") { + popupport = chrome.runtime.connect({ name: 'popup' }); + popupport.onMessage.addListener((msg: any) => { + if (msg.id in pendingcmds) { + pendingcmds[msg.id](msg); + delete pendingcmds[msg.id]; + } + }); +} // Used to call background-only APIs from content scripts @Bridged export class Platform { + static cmdid = 0; + static async openInTab(src: string, opts: { active: boolean, insert: boolean }) { if (execution_mode == 'userscript') { return GM.openInTab(src, opts); @@ -81,6 +118,34 @@ export class Platform { i = (await obj.tabs.getCurrent()).index + 1; return obj.tabs.create({ active: opts.active, url: src, index: i }); } + + static getValue(name: string, def: T) { + return localLoad(name, def); + } + + static setValue(name: string, val: any) { + localSet(name, val); + } + +} + +let cmdid = 0; +export function request(domain: string): void { + try { + popupport.postMessage({ id: cmdid, type: 'grant', domain }); + cmdid++; + } catch (e) { + if ((e as Error).message.includes("disconnected")) { + popupport = chrome.runtime.connect({ name: 'popup' }); + popupport.onMessage.addListener((msg: any) => { + if (msg.id in pendingcmds) { + pendingcmds[msg.id](msg); + delete pendingcmds[msg.id]; + } + }); + return request(domain); + } + } } async function serialize(src: any): Promise { diff --git a/src/stores.ts b/src/stores.ts index f56c031..7354d67 100644 --- a/src/stores.ts +++ b/src/stores.ts @@ -40,49 +40,7 @@ export const initial_settings = localLoad('settingsv2', { conc: 8, ho: false, blacklist: ['guro', 'scat', 'ryona', 'gore'], - rsources: [{ - name: 'Gelbooru', - domain: 'gelbooru.com', - endpoint: '/index.php?page=dapi&s=post&q=index&json=1&tags=md5:', - view: "https://gelbooru.com/index.php?page=post&s=view&id=" - }, - { - name: 'Yandere', - domain: 'yande.re', - endpoint: '/post.json?tags=md5:', - view: `https://yande.re/post/show/` - }, - { - name: 'Sankaku', - domain: 'capi-v2.sankakucomplex.com', - endpoint: '/posts/keyset?tags=md5:', - view: `https://chan.sankakucomplex.com/post/show/` - }, - { - name: 'Rule34', - domain: 'api.rule34.xxx', - endpoint: '/index.php?page=dapi&s=post&q=index&json=1&tags=md5:', - // note: rule34 do not seem to give source in their API - view: "https://rule34.xxx/index.php?page=post&s=view&id=" - }, - { - name: 'Danbooru', - domain: 'danbooru.donmai.us', - endpoint: '/posts.json?tags=md5:', - view: 'https://danbooru.donmai.us/posts/' - }, - { - name: 'Lolibooru', - domain: 'lolibooru.moe', - endpoint: '/post.json?tags=md5:', - view: 'https://lolibooru.moe/post/show/' - }, - { - name: "ATFbooru", - domain: "booru.allthefallen.moe", - endpoint: "/posts.json?tags=md5:", - view: 'https://booru.allthefallen.moe/posts/' - }] as (Omit & {view: string, disabled?: boolean})[], + rsources: [] as (Omit & {view: string, disabled?: boolean})[], ...localLoad('settingsv2', {}), });