Fix encode

fixes the encode on strawpoll (no more å for example)

  1.  
  2. // ==UserScript==
  3. // @name Fix encode
  4. // @namespace Fix encode by C4illin
  5. // @match https://www.strawpoll.me/*
  6. // @grant none
  7. // @version 1.2
  8. // @author C4illin
  9. // @description fixes the encode on strawpoll (no more å for example)
  10. // @license MIT; https://opensource.org/licenses/MIT
  11. // @copyright 2020, C4illin (https://github.com/C4illin)
  12. // ==/UserScript==
  13. function htmlDecode(input) {
  14. var doc = new DOMParser().parseFromString(input, "text/html")
  15. return doc.documentElement.textContent
  16. }
  17.  
  18. let title = document.querySelector("meta[property='og:title']").content
  19. let mainText = document.querySelector("div#result-list > h1")
  20.  
  21. if (mainText && title.endsWith("...")){
  22. title = htmlDecode(mainText.textContent)
  23. console.log(title)
  24. }
  25.  
  26. if(mainText) {
  27. mainText.textContent = title
  28. }
  29. if (title.length > 33) {
  30. title = title.slice(0, 32).trim()
  31. }
  32. document.getElementsByTagName("title")[0].textContent = (title + "… - Straw Poll")
  33.