Browse Source

Move referrer setup at startup

pull/46/head
coomdev 2 years ago
parent
commit
73d792e331
  1. 2
      main.meta.js
  2. 24
      main.user.js
  3. 3
      src/Components/Embedding.svelte
  4. 24
      src/main.ts

2
main.meta.js

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name PNGExtraEmbed // @name PNGExtraEmbed
// @namespace https://coom.tech/ // @namespace https://coom.tech/
// @version 0.170 // @version 0.171
// @description uhh // @description uhh
// @author You // @author You
// @match https://boards.4channel.org/* // @match https://boards.4channel.org/*

24
main.user.js

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name PNGExtraEmbed // @name PNGExtraEmbed
// @namespace https://coom.tech/ // @namespace https://coom.tech/
// @version 0.170 // @version 0.171
// @description uhh // @description uhh
// @author You // @author You
// @match https://boards.4channel.org/* // @match https://boards.4channel.org/*
@ -81,7 +81,7 @@
var define_BUILD_VERSION_default; var define_BUILD_VERSION_default;
var init_define_BUILD_VERSION = __esm({ var init_define_BUILD_VERSION = __esm({
"<define:BUILD_VERSION>"() { "<define:BUILD_VERSION>"() {
define_BUILD_VERSION_default = [0, 170]; define_BUILD_VERSION_default = [0, 171];
} }
}); });
@ -19606,6 +19606,7 @@
attr(source, "referrerpolicy", "no-referrer"); attr(source, "referrerpolicy", "no-referrer");
if (!src_url_equal(source.src, source_src_value = ctx[15] || ctx[6])) if (!src_url_equal(source.src, source_src_value = ctx[15] || ctx[6]))
attr(source, "src", source_src_value); attr(source, "src", source_src_value);
attr(video, "type", ctx[9]);
attr(video, "referrerpolicy", "no-referrer"); attr(video, "referrerpolicy", "no-referrer");
video.loop = video_loop_value = ctx[20].loop; video.loop = video_loop_value = ctx[20].loop;
attr(video, "class", "svelte-1uaoklw"); attr(video, "class", "svelte-1uaoklw");
@ -19619,6 +19620,9 @@
if (dirty[0] & 32832 && !src_url_equal(source.src, source_src_value = ctx2[15] || ctx2[6])) { if (dirty[0] & 32832 && !src_url_equal(source.src, source_src_value = ctx2[15] || ctx2[6])) {
attr(source, "src", source_src_value); attr(source, "src", source_src_value);
} }
if (dirty[0] & 512) {
attr(video, "type", ctx2[9]);
}
if (dirty[0] & 1048576 && video_loop_value !== (video_loop_value = ctx2[20].loop)) { if (dirty[0] & 1048576 && video_loop_value !== (video_loop_value = ctx2[20].loop)) {
video.loop = video_loop_value; video.loop = video_loop_value;
} }
@ -19794,8 +19798,10 @@
c() { c() {
video = element("video"); video = element("video");
source = element("source"); source = element("source");
attr(source, "type", ctx[9]);
if (!src_url_equal(source.src, source_src_value = ctx[15] || ctx[6])) if (!src_url_equal(source.src, source_src_value = ctx[15] || ctx[6]))
attr(source, "src", source_src_value); attr(source, "src", source_src_value);
attr(source, "data-test", "");
video.loop = video_loop_value = ctx[20].loop; video.loop = video_loop_value = ctx[20].loop;
attr(video, "class", "svelte-1uaoklw"); attr(video, "class", "svelte-1uaoklw");
}, },
@ -19805,6 +19811,9 @@
ctx[32](video); ctx[32](video);
}, },
p(ctx2, dirty) { p(ctx2, dirty) {
if (dirty[0] & 512) {
attr(source, "type", ctx2[9]);
}
if (dirty[0] & 32832 && !src_url_equal(source.src, source_src_value = ctx2[15] || ctx2[6])) { if (dirty[0] & 32832 && !src_url_equal(source.src, source_src_value = ctx2[15] || ctx2[6])) {
attr(source, "src", source_src_value); attr(source, "src", source_src_value);
} }
@ -21178,6 +21187,11 @@
}; };
}; };
var startup = async (is4chanX = true) => { var startup = async (is4chanX = true) => {
const meta2 = document.querySelector('meta[name="referrer"]');
if (meta2) {
meta2.setAttribute("name", "referrer");
meta2.setAttribute("content", "no-referrer");
}
appState.set({ ...cappState, is4chanX }); appState.set({ ...cappState, is4chanX });
const lqp = getQueryProcessor(is4chanX); const lqp = getQueryProcessor(is4chanX);
if (!lqp) if (!lqp)
@ -21309,8 +21323,10 @@
customStyles.appendChild(document.createTextNode(global_default)); customStyles.appendChild(document.createTextNode(global_default));
document.documentElement.insertBefore(customStyles, null); document.documentElement.insertBefore(customStyles, null);
var meta = document.querySelector('meta[name="referrer"]'); var meta = document.querySelector('meta[name="referrer"]');
meta.setAttribute("name", "referrer"); if (meta) {
meta.setAttribute("content", "no-referrer"); meta.setAttribute("name", "referrer");
meta.setAttribute("content", "no-referrer");
}
function processAttachments(post, ress) { function processAttachments(post, ress) {
if (ress.length == 0) if (ress.length == 0)
return; return;

3
src/Components/Embedding.svelte

@ -335,6 +335,7 @@
<!-- svelte-ignore a11y-media-has-caption --> <!-- svelte-ignore a11y-media-has-caption -->
<!-- svelte-ignore a11y-missing-attribute --> <!-- svelte-ignore a11y-missing-attribute -->
<video <video
type={ftype}
referrerpolicy="no-referrer" referrerpolicy="no-referrer"
loop={$settings.loop} loop={$settings.loop}
bind:this={videoElem} bind:this={videoElem}
@ -369,7 +370,7 @@
{#if isVideo} {#if isVideo}
<!-- svelte-ignore a11y-media-has-caption --> <!-- svelte-ignore a11y-media-has-caption -->
<video loop={$settings.loop} bind:this={hoverVideo}> <video loop={$settings.loop} bind:this={hoverVideo}>
<source src={furl || url} /> <source type={ftype} src={furl || url} data-test />
</video> </video>
<!-- assoom videos will never be loaded from thumbnails --> <!-- assoom videos will never be loaded from thumbnails -->
{/if} {/if}

24
src/main.ts

@ -2,10 +2,10 @@ import { Buffer } from "buffer";
import { appState, settings } from "./stores"; import { appState, settings } from "./stores";
import globalCss from './global.css'; import globalCss from './global.css';
import pngv3, { inject_data } from "./pngv3"; import pngv3 from "./pngv3";
import webm from "./webm"; import webm from "./webm";
import gif from "./gif"; import gif from "./gif";
import jpg, { convertToPng } from "./jpg"; import jpg from "./jpg";
import thirdeye from "./thirdeye"; import thirdeye from "./thirdeye";
import pomf from "./pomf"; import pomf from "./pomf";
@ -17,11 +17,9 @@ import SettingsButton from './Components/SettingsButton.svelte';
import Embeddings from './Components/Embeddings.svelte'; import Embeddings from './Components/Embeddings.svelte';
import EyeButton from './Components/EyeButton.svelte'; import EyeButton from './Components/EyeButton.svelte';
import NotificationsHandler from './Components/NotificationsHandler.svelte'; import NotificationsHandler from './Components/NotificationsHandler.svelte';
import { buildPeeFile, fireNotification } from "./utils"; import { fireNotification } from "./utils";
import { fileTypeFromBuffer } from "file-type";
import { getQueryProcessor, QueryProcessor } from "./websites"; import { getQueryProcessor, QueryProcessor } from "./websites";
import { lolisafe } from "./filehosts"; import { ifetch, streamRemote, supportedAltDomain } from "./platform";
import { ifetch, Platform, streamRemote, supportedAltDomain } from "./platform";
export interface ImageProcessor { export interface ImageProcessor {
skip?: true; skip?: true;
@ -253,6 +251,13 @@ const scrapeBoard = async (self: HTMLButtonElement) => {
}; };
const startup = async (is4chanX = true) => { const startup = async (is4chanX = true) => {
const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement;
if (meta) {
meta.setAttribute('name', 'referrer');
meta.setAttribute('content', 'no-referrer');
}
appState.set({ ...cappState, is4chanX }); appState.set({ ...cappState, is4chanX });
const lqp = getQueryProcessor(is4chanX); const lqp = getQueryProcessor(is4chanX);
if (!lqp) if (!lqp)
@ -409,8 +414,11 @@ const customStyles = document.createElement('style');
customStyles.appendChild(document.createTextNode(globalCss)); customStyles.appendChild(document.createTextNode(globalCss));
document.documentElement.insertBefore(customStyles, null); document.documentElement.insertBefore(customStyles, null);
const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement; const meta = document.querySelector('meta[name="referrer"]') as HTMLMetaElement;
meta.setAttribute('name', 'referrer');
meta.setAttribute('content', 'no-referrer'); if (meta) {
meta.setAttribute('name', 'referrer');
meta.setAttribute('content', 'no-referrer');
}
function processAttachments(post: HTMLDivElement, ress: [EmbeddedFile, boolean][]) { function processAttachments(post: HTMLDivElement, ress: [EmbeddedFile, boolean][]) {
if (ress.length == 0) if (ress.length == 0)

Loading…
Cancel
Save