Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion check.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ chrome.extension.onMessage.addListener(
var rpBox;
var blacklist = request.options.blacklist;
blacklist = blacklist.split("\n");
var protocols = request.options.protocols;
protocols = protocols.split("\n");
var cacheType = request.options.cache;
var checkType = request.options.checkType;
var optURL = request.options.optionsURL;
Expand All @@ -27,7 +29,7 @@ chrome.extension.onMessage.addListener(
for (var i = 0; i < pageLinks.length; i++){
var link = pageLinks[i];
var isValidLink = false;
isValidLink = isLinkValid(link,request,blacklist);
isValidLink = isLinkValid(link,request,blacklist,protocols);
if(isValidLink === true){
queued += 1;
link.classList.add("CMY_Link");
Expand Down
5 changes: 5 additions & 0 deletions css/options_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ p{
height: 200px;
}

#protocolEntries{
width: 500px;
height: 200px;
}

#logo{
background: -webkit-gradient(linear, center top, center bottom, from(white), to(#EEE));
padding: 15px 0px 10px 10px;
Expand Down
50 changes: 35 additions & 15 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,47 @@ function removeDOMElement(id){
}
}

function isLinkValid(link,request,blacklist){
function isLinkValid(link,request,blacklist,protocols){
var url = link.href;
var rel = link.rel;
var urlProtocol = link.protocol;
var protocolPermitted = false;
var blacklisted = false;

if (url.startsWith('chrome-extension://')){
return false;
}
else if ((request.nf == 'false' && rel == "nofollow") || (url.startsWith('http') === false && url.length !== 0)){
console.log("Skipped: " + url);
return false;

if ((request.options.noFollow == 'false' && rel == "nofollow") || (url.length === 0)){
return false;
}
else{
for (var b = 0; b < blacklist.length; b++)
{
if (blacklist[b] !== "" && url.contains(blacklist[b])){
blacklisted = true;
}

for (var b = 0; b < protocols.length; b++) {
if (protocols[b] !== ""
&& (!urlProtocol.contains(
protocols[b].substr(0, protocols[b].length -1))
)
){
protocolPermitted = true;
}
}

if (blacklisted === true){
console.log("Skipped (blacklisted): " + url);
return false;
if (protocolPermitted === false) {
return false;
}

for (var b = 0; b < blacklist.length; b++)
{
if (blacklist[b] !== "" && url.contains(blacklist[b])){
blacklisted = true;
}
return true;
}
return false;

if (blacklisted === true){
return false;
}

return true;
}

function clearDisplay(){
Expand Down Expand Up @@ -360,6 +375,10 @@ function getOption(key){
"googlesyndication.com\n" +
"adservices.google.com\n" +
"appliedsemantics.com",
protocols: "http\n" +
"https\n" +
"ftp\n" +
"file",
checkType: "GET",
cache: "false",
noFollow: "false",
Expand Down Expand Up @@ -396,6 +415,7 @@ function log(txt) {
function getOptions(){
var options = {};
options.blacklist = getOption("blacklist");
options.protocols = getOption("protocols");
options.checkType = getOption("checkType");
options.cache = getOption("cache");
options.noFollow = getOption("noFollow");
Expand Down
7 changes: 7 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ <h1 id="logo">Check My Links: Options</h1>
<textarea name="blacklistEntries" id="blacklistEntries" rows="2" cols="20"></textarea>
<hr/>

<p>Only links with following protocols will be checked, please enter all protocols in the whitelist below. Each protocol must be entered on a new line.</p>

<label for="protocolEntries">Protocols:</label>
<br/>
<textarea name="protocolEntries" id="protocolEntries" rows="2" cols="20"></textarea>
<hr/>

<label for="requestType">Method of Request: </label>


Expand Down
5 changes: 5 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function loadOptions() {
}

document.getElementById("blacklistEntries").value = options.blacklist.split(" ");

document.getElementById("protocolEntries").value = options.protocols.split(" ");

var requestType = document.getElementById("requestType");

for (var i = 0; i < requestType.children.length; i++) {
Expand All @@ -49,10 +52,12 @@ function loadOptions() {
function saveOptions() {
var bkg = chrome.runtime.getBackgroundPage(function(bkg){
var blacklistEntries = document.getElementById("blacklistEntries");
var protocolEntries = document.getElementById("protocolEntries");
var requestType = document.getElementById("requestType");

// Save selected options to localstore
bkg.setItem("blacklist", blacklistEntries.value);
bkg.setItem("protocols", protocolEntries.value);
bkg.setItem("checkType", requestType.children[requestType.selectedIndex].value);

if(document.getElementById("cache").checked){bkg.setItem("cache", 'true');}else{bkg.setItem("cache", 'false');}
Expand Down