FontAwesome

FontAwesome support for wenku8++

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/449713/1085791/FontAwesome.js

  1. /* eslint-disable no-multi-spaces */
  2. /* eslint-disable userscripts/no-invalid-headers */
  3. /* eslint-disable userscripts/no-invalid-grant */
  4.  
  5. // ==UserScript==
  6. // @name FontAwesome
  7. // @namespace Wenku8++
  8. // @version 0.1.3
  9. // @description FontAwesome support for wenku8++
  10. // @author PY-DNG
  11. // @license GPL-v3
  12. // @regurl https?://www\.wenku8\.net/.*
  13. // @require https://greasyfork.org/scripts/449412-basic-functions/code/Basic%20Functions.js?version=1085783
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. (function __MAIN__() {
  18. const alertify = require('alertify');
  19. const ASSETS = require('assets');
  20.  
  21. // https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/all.min.css
  22. const url = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css';
  23. const alts = [
  24. 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/all.min.css',
  25. 'https://fastly.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/all.min.css',
  26. 'https://bowercdn.net/c/fontAwesome-6.1.1/css/all.min.css',
  27. ];
  28. let i = -1;
  29.  
  30. const link = $CrE('link');
  31. link.href = url;
  32. link.rel = 'stylesheet';
  33. link.onerror = function() {
  34. i++;
  35. if (i < alts.length) {
  36. link.href = alts[i];
  37. } else {
  38. alertify.error('FontAwesome加载失败(自动重试也失败了),可能会影响一部分脚本界面图标的显示和少量界面布局,但基本不会影响功能</br>您可以将此消息<a href="https://greasyfork.org/scripts/416310/feedback" class=\'{CB}\'>反馈给开发者</a>以尝试解决问题'.replace('{CB}', ASSETS.ClassName.Button));
  39. }
  40. }
  41.  
  42. document.head.appendChild(link);
  43. })();