<fim-prefix>(function() {

	if (window.jopext_hasRun) return;
	window.jopext_hasRun = true;

	console.info('jopext: Loading content script');

	let browser_ = null;
	if (typeof browser !== 'undefined') {
		// eslint-disable-next-line no-undef
		browser_ = browser;
		// eslint-disable-next-line no-undef
		browserSupportsPromises_ = true;
	} else if (typeof chrome !== 'undefined') {
		// eslint-disable-next-line no-undef
		browser_ = chrome;
		// eslint-disable-next-line no-undef
		browserSupportsPromises_ = false;
	}

	function absoluteUrl(url) {
		if (!url) return url;
		const protocol = url.toLowerCase().split(':')[0];
		// BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
		// if (['http', 'https', 'file'].indexOf(protocol) >= 0) return url;
		// FIXED: 
<fim-middle>		if (['http', 'https', 'file', 'data'].indexOf(protocol) >= 0) return url;

		if (url.indexOf('//') === 0) {
			return location.protocol + url;
		} else if (url[0] === '/') {
			return `${location.pro<fix-suffix>tocol}//${location.host}${url}`;
		} else {
			return `${baseUrl()}/${url}`;
		}
	}

	function pageTitle() {
		const titleElements = document.getElementsByTagName('title');
		if (titleElements.length) return titleElements[0].text.trim();
		return document.title.trim();
	}

	function pageLocationOrigin() {
		// location.origin normally returns the protocol + domain + port (eg. https://example.com:8080)
		// but for file:// protocol this is browser dependant and in particular Firefox returns "null"
		// in this case.

		if (location.protocol === 'file:') {
			return 'file://';
		} else {
			return location.origin;
		}
	}

	function baseUrl() {
		let output = pageLocationOrigin() + location.pathname;
		if (output[output.length - 1] !== '/') {
			output = output.split('/');
			output.pop();
			output = output.join('/');
		}
		return output;
	}

	function getJoplinClipperSvgClassName(svg) {
		for (const className of svg.classList) {
			if (className.indexOf('joplin-clipper-svg-') === 0) ret<|endoftext|>