From ed73572165ecd12911e290b1cd8426c12cdcbbf8 Mon Sep 17 00:00:00 2001 From: coomdev Date: Fri, 11 Feb 2022 13:26:33 +0100 Subject: [PATCH] Turn off all referrers for the entire page --- main.meta.js | 2 +- main.user.js | 41 ++++++++++++++++++++------------- src/Components/Embedding.svelte | 21 ++++++++--------- src/main.ts | 3 +++ 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/main.meta.js b/main.meta.js index f4fc833..2145949 100644 --- a/main.meta.js +++ b/main.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.167 +// @version 0.168 // @description uhh // @author You // @match https://boards.4channel.org/* diff --git a/main.user.js b/main.user.js index b90be78..f25f938 100644 --- a/main.user.js +++ b/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PNGExtraEmbed // @namespace https://coom.tech/ -// @version 0.167 +// @version 0.168 // @description uhh // @author You // @match https://boards.4channel.org/* @@ -81,7 +81,7 @@ var define_BUILD_VERSION_default; var init_define_BUILD_VERSION = __esm({ ""() { - define_BUILD_VERSION_default = [0, 167]; + define_BUILD_VERSION_default = [0, 168]; } }); @@ -19596,28 +19596,32 @@ } function create_if_block_5(ctx) { let video; + let source; + let source_src_value; let video_loop_value; - let video_src_value; return { c() { video = element("video"); + source = element("source"); + attr(source, "referrerpolicy", "no-referrer"); + if (!src_url_equal(source.src, source_src_value = ctx[15] || ctx[6])) + attr(source, "src", source_src_value); attr(video, "referrerpolicy", "no-referrer"); video.loop = video_loop_value = ctx[20].loop; - if (!src_url_equal(video.src, video_src_value = ctx[15] || ctx[6])) - attr(video, "src", video_src_value); attr(video, "class", "svelte-1uaoklw"); }, m(target, anchor) { insert(target, video, anchor); + append(video, source); ctx[30](video); }, p(ctx2, dirty) { + if (dirty[0] & 32832 && !src_url_equal(source.src, source_src_value = ctx2[15] || ctx2[6])) { + attr(source, "src", source_src_value); + } if (dirty[0] & 1048576 && video_loop_value !== (video_loop_value = ctx2[20].loop)) { video.loop = video_loop_value; } - if (dirty[0] & 32832 && !src_url_equal(video.src, video_src_value = ctx2[15] || ctx2[6])) { - attr(video, "src", video_src_value); - } }, d(detaching) { if (detaching) @@ -19759,7 +19763,6 @@ return { c() { img = element("img"); - attr(img, "referrerpolicy", "no-referrer"); attr(img, "alt", img_alt_value = ctx[0].filename); if (!src_url_equal(img.src, img_src_value = ctx[15] || ctx[6])) attr(img, "src", img_src_value); @@ -19784,28 +19787,30 @@ } function create_if_block_12(ctx) { let video; + let source; + let source_src_value; let video_loop_value; - let video_src_value; return { c() { video = element("video"); - attr(video, "referrerpolicy", "no-referrer"); + source = element("source"); + if (!src_url_equal(source.src, source_src_value = ctx[15] || ctx[6])) + attr(source, "src", source_src_value); video.loop = video_loop_value = ctx[20].loop; - if (!src_url_equal(video.src, video_src_value = ctx[15] || ctx[6])) - attr(video, "src", video_src_value); attr(video, "class", "svelte-1uaoklw"); }, m(target, anchor) { insert(target, video, anchor); + append(video, source); ctx[32](video); }, p(ctx2, dirty) { + if (dirty[0] & 32832 && !src_url_equal(source.src, source_src_value = ctx2[15] || ctx2[6])) { + attr(source, "src", source_src_value); + } if (dirty[0] & 1048576 && video_loop_value !== (video_loop_value = ctx2[20].loop)) { video.loop = video_loop_value; } - if (dirty[0] & 32832 && !src_url_equal(video.src, video_src_value = ctx2[15] || ctx2[6])) { - attr(video, "src", video_src_value); - } }, d(detaching) { if (detaching) @@ -19980,6 +19985,7 @@ } if (!type) return; + $$invalidate(9, ftype = type.mime); $$invalidate(2, isVideo = type.mime.startsWith("video/")); $$invalidate(4, isAudio = type.mime.startsWith("audio/")); $$invalidate(3, isImage = type.mime.startsWith("image/")); @@ -21302,6 +21308,9 @@ var customStyles = document.createElement("style"); customStyles.appendChild(document.createTextNode(global_default)); document.documentElement.insertBefore(customStyles, null); + var meta = document.querySelector('meta[name="referrer"]'); + meta.setAttribute("name", "referrer"); + meta.setAttribute("content", "no-referrer"); function processAttachments(post, ress) { if (ress.length == 0) return; diff --git a/src/Components/Embedding.svelte b/src/Components/Embedding.svelte index 43e0113..3fcfbff 100644 --- a/src/Components/Embedding.svelte +++ b/src/Components/Embedding.svelte @@ -135,6 +135,7 @@ } } if (!type) return + ftype = type.mime; isVideo = type.mime.startsWith('video/') isAudio = type.mime.startsWith('audio/') isImage = type.mime.startsWith('image/') @@ -301,8 +302,8 @@
e.preventDefault()} - on:auxclick={(e) => e.preventDefault()} + on:click={e => e.preventDefault()} + on:auxclick={e => e.preventDefault()} on:mousedown={bepis} on:mouseover={hoverStart} on:mouseout={hoverStop} @@ -337,8 +338,9 @@ referrerpolicy="no-referrer" loop={$settings.loop} bind:this={videoElem} - src={furl || url} - /> + > + + {/if} {#if isText} @@ -362,16 +364,13 @@ >{/if} {#if isImage} - {file.filename} + {file.filename} {/if} {#if isVideo} -
diff --git a/src/main.ts b/src/main.ts index decb47b..1b73f86 100644 --- a/src/main.ts +++ b/src/main.ts @@ -408,6 +408,9 @@ document.addEventListener('QRDialogCreation', ((e: CustomEvent const customStyles = document.createElement('style'); customStyles.appendChild(document.createTextNode(globalCss)); document.documentElement.insertBefore(customStyles, null); +const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement; +meta.setAttribute('name', 'referrer'); +meta.setAttribute('content', 'no-referrer'); function processAttachments(post: HTMLDivElement, ress: [EmbeddedFile, boolean][]) { if (ress.length == 0)