aboutsummaryrefslogtreecommitdiff
path: root/content/freezer.js
blob: 9dbc95eaf32e1dca8fe77cc2fa1b33cd08b00227 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
 * Helper functions for blocking scripts in pages, based off NoScript's lib/DocumentFreezer.js
 *
 * Copyright (C) 2005-2021 Giorgio Maone - https://maone.net
 * Copyright (C) 2021 jahoti
 * Redistribution terms are gathered in the `copyright' file.
 */

const loaderAttributes = ["href", "src", "data"];
const jsOrDataUrlRx = /^(?:data:(?:[^,;]*ml|unknown-content-type)|javascript:)/i;

function sanitize_attributes(element) {
    if (element._frozen)
	return;
    let fa = [];
    let loaders = [];
    let attributes = element.attributes || [];

    for (let a of attributes) {
	let name = a.localName.toLowerCase();
	if (loaderAttributes.includes(name))
	    if (jsOrDataUrlRx.test(a.value))
		loaders.push(a);

	else if (name.startsWith("on")) {
	    console.debug("Removing", a, element.outerHTML);
	    fa.push(a.cloneNode());
	    a.value = "";
	    element[name] = null;
	}
    }
    if (loaders.length) {
	for (let a of loaders) {
	    fa.push(a.cloneNode());
	    a.value = "javascript://frozen";
	}
	if ("contentWindow" in element)
	    element.replaceWith(element = element.cloneNode(true));

    }
    if (fa.length)
	element._frozenAttributes = fa;
    element._frozen = true;
}

function mozilla_suppress_scripts(e) {
    if (document.readyState === 'complete') {
	removeEventListener('beforescriptexecute', blockExecute, true);
	console.log('Script suppressor has detached.');
	return;
    }
    if (e.isTrusted && !e.target._hachette_payload) {
	e.preventDefault();
	console.log('Suppressed script', e.target);
    }
};

/*
 * EXPORTS_START
 * EXPORT mozilla_suppress_scripts
 * EXPORT sanitize_attributes
 * EXPORTS_END
 */
logheader'>2022-09-28make repo packages (mappings) load as uninstalled; make them installable ↵Wojtek Kosior through the web UI 2022-09-28inform the web UI user about errors in communication with repositoryWojtek Kosior 2022-09-28arrange web UI Jinja templates into multiple directoriesWojtek Kosior 2022-09-28make it possible to change repo's name and URL using web UIWojtek Kosior 2022-09-28update repository last refreshal time upon refreshingWojtek Kosior 2022-09-28add styling to buttons and file inputWojtek Kosior 2022-09-28add navigation bar to web UIWojtek Kosior 2022-09-28introduce package installation state enumWojtek Kosior 2022-09-28re-enable the functionality to load packages from ZIP fileWojtek Kosior 2022-09-28allow pulling packages from remote repositoryWojtek Kosior 2022-09-28allow adding, removing and altering repositoriesWojtek Kosior This commit also temporarily breaks package import from files :/ 2022-09-28make it possible to list all repositories in the web UIWojtek Kosior 2022-09-28remove unneeded oversimplified_state_impl.pyWojtek Kosior 2022-09-28bring Hydrilla server part back to a usable stateWojtek Kosior 2022-09-28allow loading packages from zip files through web UI and listing installed ↵Wojtek Kosior mappings 2022-08-12make Haketilo proxy web UI in terms of a Flask appWojtek Kosior 2022-08-12fix REUSE complianceWojtek Kosior 2022-08-11serve a stub of meta-site for proxy configurationWojtek Kosior 2022-08-11move classes/protocols for representing HTTP requests and responses data ↵Wojtek Kosior into a separate file 2022-08-11clean up unused pieces of codeWojtek Kosior 2022-08-11populate data structures based on payloads data loaded from sqlite dbWojtek Kosior 2022-08-11save computed payloads into sqlite dbWojtek Kosior 2022-08-10small clean up for item definitions handling before dependency resolution ↵Wojtek Kosior happens 2022-08-10unfinished partial workWojtek Kosior 2022-07-16unfinished partial workWojtek Kosior 2022-05-31update to schema version 2 and hydrilla builder version 1.1-beta1Wojtek Kosior 2022-04-27make use of the 'help' parameter of click.command() decorator for localized ↵v1.0Wojtek Kosior help messages 2022-04-27fix/improve wsgi deploymentWojtek Kosior 2022-04-25support --help and --version options when running the sample wsgi script ↵Wojtek Kosior from command line 2022-04-25use pyproject.toml for pytest configuration and move all tests to tests/ ↵Wojtek Kosior directory this commit also fixes inclusion of sample source package's REUSE data in source dist (needed for automated tests) 2022-04-19bugfix: prevent default function argument from being modified upon first callWojtek Kosior 2022-04-19add support for --version option; expose --version and --help over HTTPWojtek Kosior 2022-03-08don't include schema patch version number in generated instancesv1.0-beta2Wojtek Kosior 2022-03-07fix sending of JSON definition straight from disk fileWojtek Kosior 2022-03-01update schema versions to 1.0.1Wojtek Kosior 2022-02-24send /query responses with proper mimetypev1.0-beta1Wojtek Kosior 2022-02-24adapt to change in hydrilla.util.translation()Wojtek Kosior 2022-02-22use flask.send_file() in a way comptible with WSGI deploymentWojtek Kosior 2022-02-22support Flask 1.0Wojtek Kosior