Permalink
Browse files

Added HTTP Request Type options (GET or HEAD)

  • Loading branch information...
1 parent 34b7161 commit 102c5aefab66171657afc32ba8c82942231c74f7 @ocodia committed Nov 23, 2012
Showing with 64 additions and 4 deletions.
  1. +10 −1 background.js
  2. +1 −1 manifest.json
  3. +34 −0 options.html
  4. +19 −2 options.js
View
@@ -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){
View
@@ -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"] }
}
View
@@ -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;
+ }
</style>
</head>
@@ -125,6 +146,19 @@ <h1 id="logo">Check My Links: Options</h1>
<p style="line-height: 26px">For example: <span>www.mydomain.com</span> will prevent the following links from being checked: <span>www.mydomain.com/page1.html</span> or <span>www.mydomain.com/page2.html</span></p>
<label for="blacklistEntries">Exclude links from these domains:</label><br/>
<textarea name="blacklistEntries" id="blacklistEntries" rows="2" cols="20"></textarea>
+ <hr/>
+ <div class="option_row">
+ <div class="option_name">
+ <label for="requestType">Request Type:</label> </div>
+ <div class="option_picker">
+ <select id="requestType">
+ <option value="HEAD">HEAD</option>
+ <option value="GET">GET</option>
+ </select>
+ </div>
+ </div>
+ <p style="clear:both;">HEAD is quicker, but sometimes doesn't reflect the true HTTP status of a page, switch to GET if you're getting weird results.</p>
+ <hr/>
<div class="buttons">
<button id="save">Save my preferences</button></div>
<div id="msg" style="visibility: hidden;">Preferences Saved!</div>
View
@@ -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";
}

0 comments on commit 102c5ae

Please sign in to comment.