Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial checkin

  • Loading branch information...
commit 28805b2185b647d24665f6cd9ffab18b3c400c19 1 parent adb63f2
Stoyan authored
2  wtf@phpied.com/chrome.manifest
... ... @@ -0,0 +1,2 @@
  1 +content wtf chrome/content/
  2 +overlay chrome://yslow/content/browser.xul chrome://wtf/content/browser.xul
6 wtf@phpied.com/chrome/content/browser.xul
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" id="yslow-wtf-overlay">
  3 +
  4 + <script type="application/x-javascript" src="chrome://wtf/content/wtf.js"></script>
  5 +
  6 +</overlay>
BIN  wtf@phpied.com/chrome/content/icon.png
195 wtf@phpied.com/chrome/content/wtf.js
... ... @@ -0,0 +1,195 @@
  1 +/*global YSLOW */
  2 +YSLOW.registerRule({
  3 + id: 'wtf-blink',
  4 + name: '&lt;blink&gt;',
  5 + info: "&quot;There's a lady who knows, all that blinkers is gold&quot; - Led Zeppelin",
  6 + category: ['general'],
  7 + config: {},
  8 +
  9 + lint: function (doc, cset, config) {
  10 + var count = doc.getElementsByTagName('blink').length,
  11 + message = '';
  12 +
  13 + if (count) {
  14 + message = YSLOW.util.plural('Oh my, %num% blink tag%s%, <blink style="color:red">seriously?</blink>', count);
  15 + }
  16 +
  17 + return {
  18 + score: count ? 1 : 100,
  19 + message: message
  20 + };
  21 + }
  22 +});
  23 +
  24 +
  25 +
  26 +YSLOW.registerRule({
  27 + id: 'wtf-marquee',
  28 + name: '&lt;marquee&gt;',
  29 + info: "&quot;Hello&quot; - Marqueez de Sade",
  30 + category: ['general'],
  31 + config: {},
  32 +
  33 + lint: function (doc, cset, config) {
  34 + var count = doc.getElementsByTagName('marquee').length,
  35 + message = '';
  36 +
  37 + if (count) {
  38 + message = YSLOW.util.plural('Ah-ha, %num% marquee tag%s%, impressive!', count);
  39 + }
  40 +
  41 + return {
  42 + score: count ? 1 : 100,
  43 + message: message
  44 + };
  45 + }
  46 +});
  47 +
  48 +YSLOW.registerRule({
  49 + id: 'wtf-font',
  50 + name: '&lt;font&gt;',
  51 + info: "Once upon a time, a long time a ago, before the @font-face has even been imagined, there was the &lt;font&gt; tag",
  52 + category: ['general'],
  53 + config: {
  54 + points: 21
  55 + },
  56 +
  57 + lint: function (doc, cset, config) {
  58 + var count = doc.getElementsByTagName('font').length,
  59 + message = '';
  60 +
  61 + if (count) {
  62 + message = YSLOW.util.plural('%num% font tag%s% - must be one hell of a web page', count);
  63 + }
  64 +
  65 + return {
  66 + score: count ? 100 - count * config.points : 100,
  67 + message: message
  68 + };
  69 + }
  70 +});
  71 +
  72 +YSLOW.registerRule({
  73 + id: 'wtf-doctype',
  74 + name: 'Use a doctype',
  75 + info: "Without a DOCTYPE, the page renders in quirks mode. The shortest doctype you can put at the very top of the page is <code>&lt;!doctype html&gt;</code>",
  76 + category: ['general'],
  77 + config: {},
  78 +
  79 + lint: function (doc, cset, config) {
  80 + var dtype = doc.doctype,
  81 + message = '';
  82 +
  83 + if (!dtype) {
  84 + message = "The page doesn't have a doctype";
  85 + }
  86 +
  87 + return {
  88 + score: !dtype ? 1 : 100,
  89 + message: message
  90 + };
  91 + }
  92 +});
  93 +
  94 +
  95 +YSLOW.registerRule({
  96 + id: 'wtf-spacer',
  97 + name: 'No more spacer.gif',
  98 + info: "For layout purposes, use CSS instead of spacer images",
  99 + category: ['general'],
  100 + config: {
  101 + hints: ['spacer', 'dot', 'clear', 'pixel', '1x1'],
  102 + points: 21
  103 + },
  104 +
  105 + lint: function (doc, cset, config) {
  106 + var images = doc.images,
  107 + i = 0, max = images.length,
  108 + message = '',
  109 + count = 0,
  110 + url,
  111 + img,
  112 + re = new RegExp(config.hints.join('|'), 'i');
  113 +
  114 +
  115 + for (i = 0; i < max; i += 1) {
  116 + img = images[i];
  117 + url = img.src;
  118 + url = url.split('/').pop();
  119 + if (re.test(url) && img.naturalWidth === 1 && img.naturalHeight === 1) {
  120 + count += 1;
  121 + }
  122 + }
  123 +
  124 +
  125 + if (count) {
  126 + message = YSLOW.util.plural('%num% spacer GIF%s% found', count);
  127 + }
  128 +
  129 + return {
  130 + score: count ? 100 - count * config.points : 100,
  131 + message: message
  132 + };
  133 + }
  134 +});
  135 +
  136 +
  137 +
  138 +YSLOW.registerRule({
  139 + id: 'wtf-hashlinks',
  140 + name: 'Semantic link hrefs',
  141 + info: "Links should be links. Links with href such as href=# and href=&quot;javascript:&quot; should be avoided like the plague",
  142 + category: ['general'],
  143 + config: {
  144 + points: 21
  145 + },
  146 +
  147 + lint: function (doc, cset, config) {
  148 +
  149 + var links = doc.links,
  150 + i, max = links.length,
  151 + href,
  152 + message = '',
  153 + count = 0;
  154 +
  155 + for (i = 0; i < max; i += 1) {
  156 + href = links[i].getAttribute('href').toString();
  157 + if (href === "#" || href.indexOf('javascript:') === 0) {
  158 + count += 1;
  159 + }
  160 + }
  161 +
  162 + if (count) {
  163 + message = YSLOW.util.plural('Found %num% link%s% with non-semantic href attributes', count);
  164 + }
  165 +
  166 + return {
  167 + score: count ? 100 - count * config.points : 100,
  168 + message: message
  169 + };
  170 + }
  171 +});
  172 +
  173 +
  174 +
  175 +YSLOW.registerRuleset({
  176 + id: 'wtf',
  177 + name: 'Web Testing Framework',
  178 + rules: {
  179 + 'wtf-blink': {},
  180 + 'wtf-marquee': {},
  181 + 'wtf-font': {},
  182 + 'wtf-doctype': {},
  183 + 'wtf-spacer': {},
  184 + 'wtf-hashlinks': {}
  185 + },
  186 + weights: {
  187 + 'wtf-blink': 1,
  188 + 'wtf-marquee': 1,
  189 + 'wtf-font': 1,
  190 + 'wtf-doctype': 1,
  191 + 'wtf-spacer': 1,
  192 + 'wtf-hashlinks': 1
  193 + }
  194 +});
  195 +
0  wtf@phpied.com/defaults/preferences/wtf.js
No changes.
19 wtf@phpied.com/install.rdf
... ... @@ -0,0 +1,19 @@
  1 +<?xml version="1.0"?>
  2 +<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
  3 + xmlns:NC="http://home.netscape.com/NC-rdf#"
  4 + xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  5 + <RDF:Description RDF:about="rdf:#$41y0G2"
  6 + em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
  7 + em:minVersion="2"
  8 + em:maxVersion="3.*" />
  9 + <RDF:Description RDF:about="urn:mozilla:install-manifest"
  10 + em:id="wtf@phpied.com"
  11 + em:name="Web Testing Framework"
  12 + em:version="0.0.1"
  13 + em:creator="Stoyan Stefanov"
  14 + em:description="A YSlow extension for inspecting shady webdev practices"
  15 + em:homepageURL="http://phpied.com/wtf/"
  16 + em:iconURL="chrome://wtf/content/icon.png">
  17 + <em:targetApplication RDF:resource="rdf:#$41y0G2"/>
  18 + </RDF:Description>
  19 +</RDF:RDF>

0 comments on commit 28805b2

Please sign in to comment.
Something went wrong with that request. Please try again.