forked from orbitbot/chrome-extensions-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevtools.js
30 lines (29 loc) · 1.27 KB
/
devtools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var category = chrome.experimental.devtools.audits.addCategory(
"Broken links", 1);
category.onAuditStarted.addListener(function callback(auditResults) {
chrome.extension.sendRequest({ tabId: webInspector.inspectedWindow.tabId },
function(results) {
if (!results.badlinks.length) {
auditResults.addResult("No broken links",
"There are no broken links on the page!",
auditResults.Severity.Info);
}
else {
var details = auditResults.createResult(results.badlinks.length +
" links out of " + results.total + " are broken");
for (var i = 0; i < results.badlinks.length; ++i) {
details.addChild(auditResults.createURL(results.badlinks[i].href,
results.badlinks[i].text));
}
auditResults.addResult("Broken links found (" +
results.badlinks.length +
")", "",
auditResults.Severity.Severe,
details);
}
auditResults.done();
});
});