From 102c5aefab66171657afc32ba8c82942231c74f7 Mon Sep 17 00:00:00 2001 From: Paul Livingstone Date: Fri, 23 Nov 2012 11:26:38 +0000 Subject: [PATCH] Added HTTP Request Type options (GET or HEAD) --- background.js | 11 ++++++++++- manifest.json | 2 +- options.html | 34 ++++++++++++++++++++++++++++++++++ options.js | 21 +++++++++++++++++++-- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/background.js b/background.js index 9dee8d5..e52c8f6 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,5 @@ var logging = false; +var checkType; chrome.extension.onMessage.addListener(onRequest); @@ -13,12 +14,20 @@ chrome.browserAction.onClicked.addListener(function (tab) { "adservices.google.com\n" + "appliedsemantics.com"; + var checkTypeDefault = "HEAD"; + // Set up the defaults if no values are present in LocalStorage if (getItem("blacklist") === null) { setItem("blacklist", blacklistDefaults); } + if(getItem("checkType") == null){ + setItem("checkType", checkTypeDefault); + } + + var blacklist = getItem("blacklist"); + checkType = getItem("checkType"); chrome.tabs.sendMessage(tab.id, {bl:blacklist}); }); @@ -47,7 +56,7 @@ function check(url, callback) { }; try { - xhr.open("HEAD", url, true); + xhr.open(checkType, url, true); xhr.send(); } catch(e){ diff --git a/manifest.json b/manifest.json index abf7148..6ce6363 100755 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "icons": { "128": "icon.png" }, "name": "Check My Links", "permissions": [ "tabs", "http://*/*", "https://*/*" ], - "version": "3.1.2", + "version": "3.2", "manifest_version": 2, "background": { "scripts": ["background.js"] } } diff --git a/options.html b/options.html index 268598c..5b528fd 100755 --- a/options.html +++ b/options.html @@ -115,6 +115,27 @@ border-top: 1px dashed #DDD; } + + + .option_row{ + clear:left; + } + + .option_name{ + float:left; + font-weight:bold; + margin-top:3px; + } + + .option_picker{ + float:left + } + + hr{ +border: 1px solid #EEE; +border-bottom: none; +margin: 10px 0px; + } @@ -125,6 +146,19 @@

Check My Links: Options

For example: www.mydomain.com will prevent the following links from being checked: www.mydomain.com/page1.html or www.mydomain.com/page2.html


+
+
+
+
+
+ +
+
+

HEAD is quicker, but sometimes doesn't reflect the true HTTP status of a page, switch to GET if you're getting weird results.

+
diff --git a/options.js b/options.js index 50223af..be4adfb 100755 --- a/options.js +++ b/options.js @@ -10,28 +10,45 @@ var blacklistDefaults = "adservices.google.com\n" + "appliedsemantics.com"; +var checkTypeDefault = "HEAD"; + function loadOptions() { var bkg = chrome.extension.getBackgroundPage(); var blacklistItems = bkg.getItem("blacklist"); + var checkTypeSelection = bkg.getItem("checkType"); if (blacklistItems === null) { bkg.setItem("blacklist", blacklistDefaults); } - blacklistItems = bkg.getItem("blacklist"); + if (checkTypeSelection === null) { + bkg.setItem("checkType", checkTypeDefault); + } + + //blacklistItems = bkg.getItem("blacklist"); blacklistItems.split(" "); document.getElementById("blacklistEntries").value = blacklistItems; + var requestType = document.getElementById("requestType"); + // Select the appropriate saved option for TRENDS + for (var i = 0; i < requestType.children.length; i++) { + var requestTypechild = requestType.children[i]; + if (requestTypechild.value == checkTypeSelection) { + requestTypechild.selected = "true"; + break; + } + } } function saveOptions() { var bkg = chrome.extension.getBackgroundPage(); var blacklistEntries = document.getElementById("blacklistEntries"); - + var requestType = document.getElementById("requestType"); // Save selected options to localstore bkg.setItem("blacklist", blacklistEntries.value); + bkg.setItem("checkType", requestType.children[requestType.selectedIndex].value); document.getElementById("msg").style.visibility = "visible"; }