forked from abzubarev/web-developer-form-filler-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
140 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<title></title> | ||
<script type="text/javascript" src="javascripts/parseuri.js"></script> | ||
<script type="text/javascript" src="javascripts/utils.js"></script> | ||
<script type="text/javascript" src="javascripts/background.js"></script> | ||
|
||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// parseUri 1.2.2 | ||
// (c) Steven Levithan <stevenlevithan.com> | ||
// MIT License | ||
|
||
function parseUri (str) { | ||
var o = parseUri.options, | ||
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), | ||
uri = {}, | ||
i = 14; | ||
|
||
while (i--) uri[o.key[i]] = m[i] || ""; | ||
|
||
uri[o.q.name] = {}; | ||
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { | ||
if ($1) uri[o.q.name][$1] = $2; | ||
}); | ||
|
||
return uri; | ||
}; | ||
|
||
parseUri.options = { | ||
strictMode: false, | ||
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], | ||
q: { | ||
name: "queryKey", | ||
parser: /(?:^|&)([^&=]*)=?([^&]*)/g | ||
}, | ||
parser: { | ||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, | ||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var FILTER_BY_DOMAIN = 'domain'; | ||
var FILTER_BY_PATH = 'path'; | ||
var FILTER_BY_FULL = 'full'; | ||
|
||
function fits(current, storage) { | ||
var value = localStorage.getItem('filter'); | ||
|
||
current = current.toLowerCase(); | ||
storage = storage.toLowerCase(); | ||
|
||
var url1 = parseUri(current); | ||
var url2 = parseUri(storage); | ||
|
||
if (value === FILTER_BY_DOMAIN) { | ||
return url1.host === url2.host; | ||
|
||
} else if (value === FILTER_BY_PATH) { | ||
return (url1.protocol + url1.host + url1.path) == (url2.protocol + url2.host + url2.path); | ||
|
||
} else if (value === FILTER_BY_FULL) { | ||
return current == storage; | ||
|
||
} else { | ||
console.error('WebFormFiller: filter value is wrong: ' + value); | ||
return true; | ||
} | ||
} | ||
|
||
function getSetsForCurrentUrl(url) { | ||
var sets = []; | ||
|
||
for (var i = 0; i < localStorage.length; i++) { | ||
var key = localStorage.key(i); | ||
if (key == 'filter') { | ||
continue; | ||
} | ||
|
||
var settings = JSON.parse(localStorage.getItem(key)); | ||
|
||
if (fits(url, settings.url)) { | ||
settings.key = key; | ||
sets.push(settings); | ||
} | ||
} | ||
|
||
return sets; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters