hinatazaka46-exceotionhandler

handle exception

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greatest.deepsurf.us/scripts/531764/1573301/hinatazaka46-exceotionhandler.js

  1. // ==UserScript==
  2. // @name hinatazaka46-exceptionhandler
  3. // @namespace https://greatest.deepsurf.us/ja/users/1328592-naoqv
  4. // @description handle exception
  5. // @description:ja 例外処理
  6. // @version 0.4
  7. // @match https://www.hinatazaka46.com/s/official/*
  8. // @icon https://cdn.hinatazaka46.com/files/14/hinata/img/favicons/favicon-32x32.png
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. const handleException = (proc, scriptName) => {
  14. try {
  15. const divElem = document.querySelector('html body div');
  16. if (divElem == null || divElem.innerText == null || divElem.innerText.includes('メンテナンス中')) {
  17. return;
  18. }
  19. proc();
  20. } catch (e) {
  21.  
  22. console.error(e);
  23.  
  24. const cookies = document.cookie;
  25.  
  26. const lang = CookieUtils.getCookie("wovn_selected_lang");
  27.  
  28. switch(lang) {
  29. case "ja":
  30. alert(`userscriptの処理中にエラーが発生しました。\n${scriptName}」のuserscriptを無効にしてください。`);
  31. break;
  32. case "en":
  33. case "zh-Hans":
  34. case "zh-Hant":
  35. case "ko":
  36. default:
  37. alert(`An error occurred while processining userscript.\nPlease disable the userscript:\n[${scriptName}].`);
  38. }
  39. }
  40. };