Mycroft Patch for Firefox 78

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

  1. // ==UserScript==
  2. // @name Mycroft Patch for Firefox 78
  3. // @author Jefferson "jscher2000" Scher
  4. // @namespace JeffersonScher
  5. // @version 1.0
  6. // @copyright Copyright 2020 Jefferson Scher
  7. // @license BSD-3-Clause
  8. // @description Modify page function to use supported features only. Tampermonkey or Violentmonkey. v1.0 2020-06-20
  9. // @match https://mycroftproject.com/*
  10. // @match http://mycroftproject.com/*
  11. // @grant unsafeWindow
  12. // ==/UserScript==
  13.  
  14. unsafeWindow.addOpenSearch = function(name,ext,cat,pid,meth) {
  15. var title = event.target.textContent;
  16. // Update the page favicon to pass to the browser
  17. var favicon = document.querySelector('link[rel="icon"]');
  18. if (favicon){
  19. if (ext == 'ico') favicon.setAttribute('type', 'image/vnd.microsoft.icon');
  20. else favicon.setAttribute('type', 'image/' + ext);
  21. favicon.href = 'https://mycroftproject.com/updateos.php/id0/' + name + '.' + ext;
  22. } else {
  23. favicon = document.createElement('link');
  24. favicon.setAttribute('rel', 'icon');
  25. if (ext == 'ico') favicon.setAttribute('type', 'image/vnd.microsoft.icon');
  26. else favicon.setAttribute('type', 'image/' + ext);
  27. favicon.href = 'https://mycroftproject.com/updateos.php/id0/' + name + '.' + ext;
  28. document.getElementsByTagName('head')[0].appendChild(oslink);
  29. }
  30. // Add a new link tag for the specified search engine
  31. var oslink = document.querySelector('link[rel="search"][type="application/opensearchdescription+xml"]');
  32. if (oslink){
  33. oslink.remove();
  34. }
  35. oslink = document.createElement('link');
  36. oslink.setAttribute('rel', 'search');
  37. oslink.setAttribute('type', 'application/opensearchdescription+xml');
  38. oslink.setAttribute('title', title);
  39. oslink.href = 'https://mycroftproject.com/installos.php/' + pid + '/' + name + '.xml';
  40. document.getElementsByTagName('head')[0].appendChild(oslink);
  41. // Enable visibility of instructional message
  42. var howtomsg = document.getElementById('howtomsg');
  43. if (!howtomsg){
  44. howtomsg = document.createElement('div');
  45. howtomsg.id = 'howtomsg';
  46. 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;');
  47. document.body.appendChild(howtomsg);
  48. }
  49. howtomsg.innerHTML = 'Now use the Page Actions menu (•••) in the address bar to add the "' + title + '" search engine to Firefox.';
  50. howtomsg.style.display = 'block';
  51. };

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址