-
Notifications
You must be signed in to change notification settings - Fork 15
/
ouiseo.min.js
1 lines (1 loc) · 8.18 KB
/
ouiseo.min.js
1
;(function(){function r(){function e(){return"<script id='ouiseo-ga'>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-23209172-7', window.location.hostname);ga('send', 'pageview');</script>"}function t(){var e="";e+=n().outerHTML;e+=r().outerHTML;return e}function n(){var e=document.createElement("div");e.id="ouiseo_frame";return e}function r(){var e=i();var t=s();t.appendChild(o());t.appendChild(u());t.appendChild(a());t.appendChild(l());t.appendChild(p());t.appendChild(d());t.appendChild(v());t.appendChild(m());e.appendChild(t);var n=g();n.appendChild(y());n.appendChild(b());e.appendChild(n);return e}function i(){var e=document.createElement("div"),t=document.createElement("h1");e.id="ouiseo";e.className="ouiseo";t.id="ouiseo-author";t.innerHTML="Made by ";t.innerHTML+='<a href="http://www.carlsednaoui.com?utm_campaign=ouiseo&utm_medium=widget-link&utm_source=ouiseo-browser-extension" target="_blank">Carl Sednaoui</a>';t.innerHTML+=" - Open sourced on ";t.innerHTML+='<a href="https://github.com/carlsednaoui/ouiseo" target="_blank">Github</a>';e.appendChild(t);return e}function s(){var e=document.createElement("div");e.id="ouiseo-basic-seo";var t=document.createElement("h2");t.innerHTML="SEO";e.appendChild(t);return e}function o(){var e=document.createElement("p"),t=document.createElement("span"),n=document.createElement("input");e.className="ouiseo-basic-result";t.id="ouiseo-title-length";n.type="text";n.id="ouiseo-title";n.className="ouiseo-input-text";var r=$("title").text()||"";var i=0;if(!!r)i=r.replace(/\n$/,"").length;t.innerHTML=i;n.setAttribute("value",r);e.innerHTML="Title (";e.appendChild(t);e.innerHTML+=")";e.appendChild(n);return e}function u(){var e=document.createElement("p"),t=document.createElement("span"),n=document.createElement("input");e.className="ouiseo-basic-result";t.id="ouiseo-description-length";n.type="text";n.id="ouiseo-description";n.className="ouiseo-input-text";var r=$("meta[name=description]").attr("content")||"";var i=0;if(!!r)i=r.replace(/\n$/,"").length;t.innerHTML=i;n.setAttribute("value",r);e.innerHTML="Meta Description (";e.appendChild(t);e.innerHTML+=")";e.appendChild(n);return e}function a(){var e=document.createElement("p"),t=document.createElement("span"),n=document.createElement("input");e.className="ouiseo-basic-result";t.id="ouiseo-keywords-length";n.type="text";n.id="ouiseo-keywords";n.className="ouiseo-input-text";var r=$("meta[name=keywords]").attr("content")||"";var i=0;if(r!=="")i=r.split(",").length;t.innerHTML=i;n.setAttribute("value",r);e.innerHTML="Meta Keywords (";e.appendChild(t);e.innerHTML+=")";e.appendChild(n);return e}function f(){var e=0;$.each($("img"),function(t){if($("img")[t].alt)e++});return e==[]?0:e}function l(){var e=document.createElement("p");e.className="ouiseo-basic-result";var t=$("img").length,n=f();e.innerHTML="Images with alt text: ";e.innerHTML+=n;e.innerHTML+=" out of ";e.innerHTML+=t;return e}function c(){var e=0;$.each($("a"),function(t){if($("a")[t].title!=="")e++});return e==[]?0:e}function h(){var e=0;$.each($("a"),function(t){if($("a")[t].rel=="nofollow")e++});return e}function p(){var e=document.createElement("p");e.className="ouiseo-basic-result";var t=$("a").length,n=c(),r=h();e.innerHTML="Links with title set: ";e.innerHTML+=n;e.innerHTML+=" out of ";e.innerHTML+=t;e.innerHTML+=" links. This page has ";e.innerHTML+=r;e.innerHTML+=" nofollow links.";return e}function d(){var e=document.createElement("p");e.className="ouiseo-basic-result";var t=$("h1").length||0,n=$("h2").length||0,r=$("h3").length||0;e.innerHTML="H1: ";e.innerHTML+=t;e.innerHTML+="<br> H2: ";e.innerHTML+=n;e.innerHTML+="<br> H3: ";e.innerHTML+=r;return e}function v(){var e=document.createElement("p");e.className="ouiseo-basic-result";var t=$("link[rel='canonical']").length||0;e.innerHTML="Rel Canonical (";e.innerHTML+=t;e.innerHTML+=")";if(t!==0){$.each($("link[rel='canonical']"),function(t){e.innerHTML+="<br>";e.innerHTML+=$("link[rel='canonical']")[t].href})}return e}function m(){var e=document.createElement("p"),t=document.createElement("span"),n=document.createElement("input");e.className="ouiseo-basic-result";t.id="ouiseo-cookie-count";n.type="text";n.id="ouiseo-cookie";n.className="ouiseo-input-text";var r=document.cookie;n.setAttribute("value",r);t.innerHTML="0";if(r!=="")t.innerHTML=r.split(";").length;e.innerHTML="Site cookie: (";e.appendChild(t);e.innerHTML+=")";e.appendChild(n);return e}function g(){var e=document.createElement("div");e.id="ouiseo-social-section";return e}function y(){var e=document.createElement("div");title=document.createElement("h2");e.id="ouiseo-facebook";title.innerHTML="Facebook";e.appendChild(title);e.appendChild(E("FB App Id","fb-app-id",'meta[property="fb:app_id"]'));e.appendChild(E("OG URL","fb-url",'meta[property="og:url"]'));e.appendChild(E("OG Site Name","fb-site-name",'meta[property="og:site_name"]'));e.appendChild(E("OG Title","fb-title",'meta[property="og:title"]'));e.appendChild(E("OG Description","fb-description",'meta[property="og:description"]'));e.appendChild(E("OG Type","fb-type",'meta[property="og:type"]'));e.appendChild(S("OG Image",'meta[property="og:image"]'));return e}function b(){var e=document.createElement("div");title=document.createElement("h2");e.id="ouiseo-twitter";title.innerHTML="Twitter";e.appendChild(title);e.appendChild(E("Card type","twitter-card-type",'meta[name="twitter:card"]'));e.appendChild(w("Site","twitter-site",'meta[name="twitter:site"]','meta[name="twitter:site:id"]'));e.appendChild(w("Creator","twitter-creator",'meta[name="twitter:creator"]','meta[name="twitter:creator:id"]'));e.appendChild(E("Card title","twitter-card-title",'meta[name="twitter:title"]'));e.appendChild(E("Card description","twitter-card-description",'meta[name="twitter:description"]'));e.appendChild(S("Image",'meta[name="twitter:image:src"]'));return e}function w(e,t,n,r){var i=document.createElement("p"),s=document.createElement("input"),o;i.className="ouiseo-social-result";s.type="text";s.id="ouiseo-"+t;s.className="ouiseo-input-text";i.innerHTML=e;if($(n)[0]){o=$(n)[0].content}else if($(r)[0]){i.innerHTML+=" ID";o=$(r)[0].content}else{o=""}s.setAttribute("value",o);i.appendChild(s);return i}function E(e,t,n){var r=document.createElement("p"),i=document.createElement("input"),s;r.className="ouiseo-social-result";i.type="text";i.id="ouiseo-"+t;i.className="ouiseo-input-text";s=$(n)[0]?$(n)[0].content:"";r.innerHTML=e;i.setAttribute("value",s);r.appendChild(i);return r}function S(e,t){var n=document.createElement("p");n.className="ouiseo-social-result";n.innerHTML=e;if($(t)[0]){n.appendChild(document.createElement("div"));var r=document.createElement("img");r.src=$(t)[0].content;r.className="ouiseo-social-image";n.appendChild(r)}else{n.innerHTML+=": none"}return n}function x(){function e(e){return $(e).val().length}$("#ouiseo-title").keyup(function(){$("#ouiseo-title-length").text(e("#ouiseo-title"))});$("#ouiseo-description").keyup(function(){$("#ouiseo-description-length").text(e("#ouiseo-description"))});$("#ouiseo-keywords").keyup(function(){$("#ouiseo-keywords-length").text($("#ouiseo-keywords").val().split(",").length)})}(window.ouiseo=function(){$("head").append("<link rel='stylesheet' id='ouiseo-styles' href='//carlsednaoui.s3.amazonaws.com/ouiseo/ouiseo.css'>");$("body").append(t());x();$("#ouiseo").fadeIn(250);$("head").append(e());$("#ouiseo_frame").click(function(e){$("#ouiseo").fadeOut(750);$("#ouiseo_frame").slideUp(750);setTimeout("$('#ouiseo_frame').remove()",750);setTimeout("$('#ouiseo-styles').remove()",750);setTimeout("$('#ouiseo-ga').remove()",750);setTimeout("$('#ouiseo').remove()",750)})})()}var e="1.10.2";if(window.jQuery===undefined||window.jQuery.fn.jquery<e){var t=false,n=document.createElement("script");n.src="//ajax.googleapis.com/ajax/libs/jquery/"+e+"/jquery.min.js";n.onload=n.onreadystatechange=function(){if(!t&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){t=true;r()}};console.log("ouiseo loaded jQuery v%s",e);document.getElementsByTagName("head")[0].appendChild(n)}else{r()}})();