Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fuckms-refreshtokensync
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
msc
fuckms-refreshtokensync
Commits
807422d5
There was an error fetching the commit references. Please try again later.
Commit
807422d5
authored
7 years ago
by
didierfred
Browse files
Options
Downloads
Patches
Plain Diff
add modify header format support and check url pattern
parent
d91fd19d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
background.js
+4
-1
4 additions, 1 deletion
background.js
popup/config.html
+5
-3
5 additions, 3 deletions
popup/config.html
popup/config.js
+44
-6
44 additions, 6 deletions
popup/config.js
with
53 additions
and
10 deletions
background.js
+
4
−
1
View file @
807422d5
...
...
@@ -148,8 +148,11 @@ function notify(message)
*/
function
addListener
()
{
var
target
=
config
.
target_page
;
if
((
target
==
"
*
"
)
||
(
target
==
""
)
||
(
target
==
"
"
))
target
=
"
<all_urls>
"
;
browser
.
webRequest
.
onBeforeSendHeaders
.
addListener
(
rewriteHeader
,
{
urls
:
[
config
.
target
_page
]},
{
urls
:
[
target
]},
[
"
blocking
"
,
"
requestHeaders
"
]);
}
...
...
This diff is collapsed.
Click to expand it.
popup/config.html
+
5
−
3
View file @
807422d5
...
...
@@ -53,7 +53,7 @@ color: #008CBA;
<td
width=
"450"
>
Url Pattern :
<input
size=
"50"
id=
"targetPage"
type=
"text"
value=
""
></input>
Url Pattern
*
:
<input
size=
"50"
id=
"targetPage"
type=
"text"
value=
""
></input>
</td>
<td
width=
"270"
align=
"right"
>
...
...
@@ -78,12 +78,14 @@ color: #008CBA;
<br>
<input
type=
"button"
class=
"button"
style=
"width:100px"
id=
"add_button"
value=
"Add new line"
></input>
<input
type=
"button"
class=
"button"
style=
"width:100px"
id=
"save_button"
value=
"Save"
></input>
<br>
<br>
</center>
</i>
* Informations on url pattern can be found
<a
href=
"https://developer.chrome.com/extensions/match_patterns"
target=
"_blank"
>
here
</a>
</i>
<iframe
id=
"download"
width=
"0"
height=
"0"
frameBorder=
"0"
>
</iframe>
</center>
<br>
<script
type=
"text/javascript"
src=
"config.js"
>
</script>
...
...
This diff is collapsed.
Click to expand it.
popup/config.js
+
44
−
6
View file @
807422d5
...
...
@@ -69,8 +69,23 @@ function create_configuration_data()
return
JSON
.
stringify
(
to_export
);
}
// check if url pattern is valid
function
isTargetValid
(
target
)
{
if
(
target
==
""
)
return
true
;
if
(
target
==
"
"
)
return
true
;
if
(
target
==
"
*
"
)
return
true
;
return
target
.
match
(
"
(http|https):
\
/
\
/.[^
\
*]*
\
/
"
);
}
function
save_data
()
{
if
(
!
isTargetValid
(
document
.
getElementById
(
'
targetPage
'
).
value
))
{
alert
(
"
Url pattern is invalid
"
);
return
;
}
localStorage
.
setItem
(
"
config
"
,
create_configuration_data
());
browser
.
runtime
.
sendMessage
(
"
reload
"
);
}
...
...
@@ -113,18 +128,19 @@ function import_data(evt)
function
readSingleFile
(
e
)
{
var
file
=
e
.
target
.
files
[
0
];
if
(
!
file
)
{
var
file
=
e
.
target
.
files
[
0
];
if
(
!
file
)
{
return
;
}
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
var
contents
=
e
.
target
.
result
;
var
config
=
""
;
try
{
config
=
JSON
.
parse
(
contents
);
// check file format
if
(
config
.
format_version
&&
config
.
target_page
)
{
// store the conf in the local storage
...
...
@@ -134,14 +150,36 @@ function readSingleFile(e)
// reload the configuration page with the new conf
document
.
location
.
href
=
"
config.html
"
;
}
else
alert
(
"
invalid file format
"
);
else
{
// try modify header add-on file format : array of {action,name,value,comment,enabled}
if
(
config
[
0
].
action
)
{
var
headers
=
[];
for
(
var
line_to_load
of
config
)
{
var
enabled
=
"
off
"
;
if
(
line_to_load
.
enabled
)
enabled
=
"
on
"
if
(
line_to_load
.
action
==
"
Filter
"
)
line_to_load
.
action
=
"
delete
"
;
headers
.
push
({
action
:
line_to_load
.
action
.
toLowerCase
(),
header_name
:
line_to_load
.
name
,
header_value
:
line_to_load
.
value
,
comment
:
line_to_load
.
comment
,
status
:
enabled
});
}
var
to_load
=
{
format_version
:
"
1.0
"
,
target_page
:
""
,
headers
:
headers
};
// store the conf in the local storage
localStorage
.
setItem
(
"
config
"
,
JSON
.
stringify
(
to_load
));
// load the new conf
browser
.
runtime
.
sendMessage
(
"
reload
"
);
// reload the configuration page with the new conf
document
.
location
.
href
=
"
config.html
"
;
}
else
alert
(
"
invalid file format
"
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
alert
(
"
Invalid file format
"
);
}
alert
(
contents
);
};
reader
.
readAsText
(
file
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment