Mycroft Patch for Firefox 78

Modify page function to use supported features only. Tampermonkey or Violentmonkey. v1.0 2020-06-20

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Mycroft Patch for Firefox 78
// @author      Jefferson "jscher2000" Scher
// @namespace   JeffersonScher
// @version     1.0
// @copyright   Copyright 2020 Jefferson Scher
// @license     BSD-3-Clause
// @description Modify page function to use supported features only. Tampermonkey or Violentmonkey. v1.0 2020-06-20
// @match       https://mycroftproject.com/*
// @match       http://mycroftproject.com/*
// @grant       unsafeWindow
// ==/UserScript==

unsafeWindow.addOpenSearch = function(name,ext,cat,pid,meth) {
  var title = event.target.textContent;
	// Update the page favicon to pass to the browser
	var favicon = document.querySelector('link[rel="icon"]');
	if (favicon){
		if (ext == 'ico') favicon.setAttribute('type', 'image/vnd.microsoft.icon');
		else favicon.setAttribute('type', 'image/' + ext);
		favicon.href = 'https://mycroftproject.com/updateos.php/id0/' + name + '.' + ext;
	} else {
		favicon = document.createElement('link');
		favicon.setAttribute('rel', 'icon');
		if (ext == 'ico') favicon.setAttribute('type', 'image/vnd.microsoft.icon');
		else favicon.setAttribute('type', 'image/' + ext);
		favicon.href = 'https://mycroftproject.com/updateos.php/id0/' + name + '.' + ext;
		document.getElementsByTagName('head')[0].appendChild(oslink);
	}
	// Add a new link tag for the specified search engine
	var oslink = document.querySelector('link[rel="search"][type="application/opensearchdescription+xml"]');
	if (oslink){
		oslink.remove();
	}
	oslink = document.createElement('link');
	oslink.setAttribute('rel', 'search');
	oslink.setAttribute('type', 'application/opensearchdescription+xml');
	oslink.setAttribute('title', title);
	oslink.href = 'https://mycroftproject.com/installos.php/' + pid + '/' + name + '.xml';
	document.getElementsByTagName('head')[0].appendChild(oslink);
	// Enable visibility of instructional message
	var howtomsg = document.getElementById('howtomsg');
	if (!howtomsg){
		howtomsg = document.createElement('div');
    howtomsg.id = 'howtomsg';
		howtomsg.setAttribute('style', 'position:fixed; top:0; left:25%; width: 50%; text-align: center; padding: 0.75em; border: 2px solid #008; border-radius: 4px; color: #000; background-color: #bee;');
		document.body.appendChild(howtomsg);
	}
	howtomsg.innerHTML = 'Now use the Page Actions menu (•••) in the address bar to add the "' + title + '" search engine to Firefox.';
	howtomsg.style.display = 'block';
};