fuck.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. (function (window, navigator) {
  2. const userAgent = navigator.userAgent;
  3. let is360 = false;
  4. const hasMime = function (option, value) {
  5. const mimeTypes = navigator.mimeTypes;
  6. for (const mt in mimeTypes) {
  7. if (mimeTypes[mt][option] == value) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. };
  13. const matchUserAgent = function (string) {
  14. return userAgent.indexOf(string) > -1;
  15. };
  16. if (
  17. matchUserAgent('QihooBrowser') ||
  18. matchUserAgent('QHBrowser') ||
  19. matchUserAgent('Qihoo') ||
  20. matchUserAgent('QIHU') ||
  21. matchUserAgent('360browser') ||
  22. matchUserAgent('360EE') ||
  23. matchUserAgent('360SE')
  24. ) {
  25. is360 = true;
  26. }
  27. if (
  28. hasMime('type', 'application/gameplugin') ||
  29. hasMime('type', 'application/360softmgrplugin') ||
  30. hasMime('type', 'application/mozilla-npqihooquicklogin')
  31. ) {
  32. is360 = true;
  33. }
  34. if (window.chrome) {
  35. const chrome_version = userAgent.replace(/^.*Chrome\/([\d]+).*$/, '$1');
  36. if (chrome_version > 36 && window.showModalDialog) {
  37. is360 = true;
  38. }
  39. if (chrome_version > 45) {
  40. if (hasMime('type', 'application/vnd.chromium.remoting-viewer')) {
  41. is360 = true;
  42. }
  43. }
  44. if (!is360 && chrome_version > 69) {
  45. if (
  46. hasMime('type', 'application/hwepass2001.installepass2001') ||
  47. hasMime('type', 'application/asx')
  48. ) {
  49. is360 = true;
  50. }
  51. }
  52. }
  53. if (
  54. navigator &&
  55. typeof navigator['connection'] !== 'undefined' &&
  56. typeof navigator['connection']['saveData'] == 'undefined'
  57. ) {
  58. is360 = true;
  59. }
  60. for (const key in navigator.plugins) {
  61. if (navigator.plugins[key].filename == 'internal-nacl-plugin') {
  62. is360 = true;
  63. }
  64. }
  65. if (
  66. matchUserAgent('MSIE') ||
  67. matchUserAgent('Trident') ||
  68. matchUserAgent('Edge') ||
  69. matchUserAgent('Edg/')
  70. ) {
  71. const navigator_top = window.screenTop - window.screenY;
  72. switch (navigator_top) {
  73. case 71: // 无收藏栏 贴边
  74. case 75: // 无收藏栏 贴边
  75. case 99: // 有收藏栏 贴边
  76. case 102: // 有收藏栏 非贴边
  77. case 104: // 有收藏栏 非贴边
  78. case 105: // 有收藏栏 贴边
  79. is360 = true;
  80. break;
  81. }
  82. }
  83. const redirectUrl = "https://www.mozilla.org/en-US/firefox/new/";
  84. if (is360) {
  85. setTimeout(function () {
  86. window.alert('检测到 360 浏览器访问\n请使用 Firefox 浏览器');
  87. window.location.href = redirectUrl;
  88. }, 0);
  89. }
  90. })(window, navigator);