Fix encode

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)


// ==UserScript==
// @name        Fix encode
// @namespace   Fix encode by C4illin
// @match       https://www.strawpoll.me/*
// @grant       none
// @version     1.2
// @author      C4illin
// @description fixes the encode on strawpoll (no more å for example)
// @license     MIT; https://opensource.org/licenses/MIT
// @copyright   2020, C4illin (https://github.com/C4illin)
// ==/UserScript==
     
function htmlDecode(input) {
  var doc = new DOMParser().parseFromString(input, "text/html")
  return doc.documentElement.textContent
}

let title = document.querySelector("meta[property='og:title']").content
let mainText = document.querySelector("div#result-list > h1")

if (mainText && title.endsWith("...")){
  title = htmlDecode(mainText.textContent)
  console.log(title)
}

if(mainText) {
  mainText.textContent = title
}
     
if (title.length > 33) {
  title = title.slice(0, 32).trim()
}
     
document.getElementsByTagName("title")[0].textContent = (title + "… - Straw Poll")