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
ada368bd
There was an error fetching the commit references. Please try again later.
Commit
ada368bd
authored
7 years ago
by
didierfred
Browse files
Options
Downloads
Patches
Plain Diff
minor modification and comments
parent
26310f92
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
+1
-3
1 addition, 3 deletions
background.js
popup/config.html
+21
-14
21 additions, 14 deletions
popup/config.html
popup/config.js
+46
-10
46 additions, 10 deletions
popup/config.js
with
68 additions
and
27 deletions
background.js
+
1
−
3
View file @
ada368bd
...
@@ -10,8 +10,6 @@
...
@@ -10,8 +10,6 @@
"
use strict
"
;
"
use strict
"
;
//var targetPage = "https://httpbin.org/*";
//var modifyTable = [];
var
config
;
var
config
;
var
started
=
"
off
"
;
var
started
=
"
off
"
;
...
@@ -23,7 +21,7 @@ if (localStorage.getItem('config'))
...
@@ -23,7 +21,7 @@ if (localStorage.getItem('config'))
}
}
else
else
{
{
// else check if old config exist
// else check if old config exist
(Simple Modify headers V1.1)
if
(
localStorage
.
getItem
(
'
targetPage
'
)
&&
localStorage
.
getItem
(
'
modifyTable
'
))
if
(
localStorage
.
getItem
(
'
targetPage
'
)
&&
localStorage
.
getItem
(
'
modifyTable
'
))
{
{
console
.
log
(
"
Load old config
"
);
console
.
log
(
"
Load old config
"
);
...
...
This diff is collapsed.
Click to expand it.
popup/config.html
+
21
−
14
View file @
ada368bd
...
@@ -5,17 +5,19 @@
...
@@ -5,17 +5,19 @@
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<title>
Simple Modify Headers
</title>
<title>
Simple Modify Headers
</title>
<style
type=
"text/css"
>
<style
type=
"text/css"
>
.button
{
.button
{
background-color
:
#008CBA
;
/* Blue */
background-color
:
#008CBA
;
/* Blue */
border
:
none
;
border
:
none
;
color
:
white
;
color
:
white
;
text-align
:
center
;
text-align
:
center
;
text-decoration
:
none
;
text-decoration
:
none
;
display
:
inline-block
;
display
:
inline-block
;
font-size
:
14px
;
font-size
:
14px
;
border-radius
:
4px
;
border-radius
:
4px
;
height
:
20px
;
height
:
20px
;
}
}
.button
:hover
{
.button
:hover
{
background-color
:
#0070A0
;
background-color
:
#0070A0
;
}
}
...
@@ -31,12 +33,17 @@
...
@@ -31,12 +33,17 @@
}
}
.colonne
{
.colonne
{
background-color
:
#008CBA
;
/* Blue */
background-color
:
#008CBA
;
/* Blue */
color
:
white
;
color
:
white
;
font-size
:
14px
;
}
.text
{
font-size
:
14px
;
}
}
.title
{
.title
{
color
:
#008CBA
;
color
:
#008CBA
;
}
}
</style>
</style>
</head>
</head>
...
@@ -53,7 +60,7 @@ color: #008CBA;
...
@@ -53,7 +60,7 @@ color: #008CBA;
</h2>
</h2>
</td></tr>
</td></tr>
<tr><td>
<tr><td
class=
"text"
>
...
@@ -66,8 +73,8 @@ color: #008CBA;
...
@@ -66,8 +73,8 @@ color: #008CBA;
</td></tr>
</td></tr>
<tr><td>
<tr><td>
<br>
<br>
<br>
<br>
<table
id=
"config_tab"
id=
"config"
>
<table
id=
"config_tab"
id=
"config"
>
<tr
class=
"colonne"
>
<tr
class=
"colonne"
>
<td>
Action
</td>
<td>
Action
</td>
...
@@ -79,7 +86,7 @@ color: #008CBA;
...
@@ -79,7 +86,7 @@ color: #008CBA;
</table>
</table>
</td></tr>
</td></tr>
<tr><td>
<tr><td
class=
"text"
>
<center>
<center>
<br>
<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=
"add_button"
value=
"Add new line"
></input>
...
...
This diff is collapsed.
Click to expand it.
popup/config.js
+
46
−
10
View file @
ada368bd
...
@@ -13,6 +13,7 @@ var line_number = 1;
...
@@ -13,6 +13,7 @@ var line_number = 1;
var
started
=
"
off
"
;
var
started
=
"
off
"
;
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
// load configuration from local storage
var
config
=
JSON
.
parse
(
localStorage
.
getItem
(
"
config
"
));
var
config
=
JSON
.
parse
(
localStorage
.
getItem
(
"
config
"
));
for
(
var
to_add
of
config
.
headers
)
appendLine
(
to_add
.
action
,
to_add
.
header_name
,
to_add
.
header_value
,
to_add
.
comment
,
to_add
.
status
);
for
(
var
to_add
of
config
.
headers
)
appendLine
(
to_add
.
action
,
to_add
.
header_name
,
to_add
.
header_value
,
to_add
.
comment
,
to_add
.
status
);
document
.
getElementById
(
'
save_button
'
).
addEventListener
(
'
click
'
,
function
(
e
)
{
save_data
();});
document
.
getElementById
(
'
save_button
'
).
addEventListener
(
'
click
'
,
function
(
e
)
{
save_data
();});
...
@@ -26,7 +27,9 @@ window.onload = function() {
...
@@ -26,7 +27,9 @@ window.onload = function() {
if
(
started
==
"
on
"
)
document
.
getElementById
(
"
start_img
"
).
src
=
"
img/stop.png
"
;
if
(
started
==
"
on
"
)
document
.
getElementById
(
"
start_img
"
).
src
=
"
img/stop.png
"
;
}
;
}
;
/**
* Add a new configuration line on the UI
**/
function
appendLine
(
action
,
header_name
,
header_value
,
comment
,
status
)
{
function
appendLine
(
action
,
header_name
,
header_value
,
comment
,
status
)
{
var
html
=
"
<td><select class=
\"
select_field
\"
id=
\"
select_action
"
+
line_number
+
"
\"
disable=false><option value=
\"
add
\"
>add</option><option value=
\"
modify
\"
>modify</option><option value=
\"
delete
\"
>delete</option></select></td>
"
;
var
html
=
"
<td><select class=
\"
select_field
\"
id=
\"
select_action
"
+
line_number
+
"
\"
disable=false><option value=
\"
add
\"
>add</option><option value=
\"
modify
\"
>modify</option><option value=
\"
delete
\"
>delete</option></select></td>
"
;
...
@@ -50,6 +53,11 @@ document.getElementById('delete_button'+line_number).addEventListener('click',fu
...
@@ -50,6 +53,11 @@ document.getElementById('delete_button'+line_number).addEventListener('click',fu
line_number
++
;
line_number
++
;
}
}
/**
* Create a JSON String representing the configuration data
*
**/
function
create_configuration_data
()
function
create_configuration_data
()
{
{
var
tr_elements
=
document
.
querySelectorAll
(
"
#config_tab tr
"
);
var
tr_elements
=
document
.
querySelectorAll
(
"
#config_tab tr
"
);
...
@@ -63,21 +71,23 @@ function create_configuration_data()
...
@@ -63,21 +71,23 @@ function create_configuration_data()
var
comment
=
tr_elements
[
i
].
childNodes
[
3
].
childNodes
[
0
].
value
;
var
comment
=
tr_elements
[
i
].
childNodes
[
3
].
childNodes
[
0
].
value
;
var
status
=
tr_elements
[
i
].
childNodes
[
4
].
childNodes
[
0
].
value
;
var
status
=
tr_elements
[
i
].
childNodes
[
4
].
childNodes
[
0
].
value
;
headers
.
push
({
action
:
action
,
header_name
:
header_name
,
header_value
:
header_value
,
comment
:
comment
,
status
:
status
});
headers
.
push
({
action
:
action
,
header_name
:
header_name
,
header_value
:
header_value
,
comment
:
comment
,
status
:
status
});
}
}
var
to_export
=
{
format_version
:
"
1.0
"
,
target_page
:
document
.
getElementById
(
'
targetPage
'
).
value
,
headers
:
headers
};
var
to_export
=
{
format_version
:
"
1.0
"
,
target_page
:
document
.
getElementById
(
'
targetPage
'
).
value
,
headers
:
headers
};
console
.
log
(
JSON
.
stringify
(
to_export
));
return
JSON
.
stringify
(
to_export
);
return
JSON
.
stringify
(
to_export
);
}
}
// check if url pattern is valid , if not , set the font color to red
/**
* check if url pattern is valid , if not , set the font color to red
**/
function
checkTargetPageField
()
function
checkTargetPageField
()
{
{
if
(
isTargetValid
(
document
.
getElementById
(
'
targetPage
'
).
value
))
document
.
getElementById
(
'
targetPage
'
).
style
.
color
=
"
black
"
;
if
(
isTargetValid
(
document
.
getElementById
(
'
targetPage
'
).
value
))
document
.
getElementById
(
'
targetPage
'
).
style
.
color
=
"
black
"
;
else
document
.
getElementById
(
'
targetPage
'
).
style
.
color
=
"
red
"
;
else
document
.
getElementById
(
'
targetPage
'
).
style
.
color
=
"
red
"
;
}
}
// check if url pattern is valid
/**
* check if url pattern is valid
**/
function
isTargetValid
(
target
)
function
isTargetValid
(
target
)
{
{
if
(
target
==
""
)
return
true
;
if
(
target
==
""
)
return
true
;
...
@@ -85,22 +95,32 @@ function isTargetValid(target)
...
@@ -85,22 +95,32 @@ function isTargetValid(target)
if
(
target
==
"
*
"
)
return
true
;
if
(
target
==
"
*
"
)
return
true
;
return
target
.
match
(
"
(http|https|[
\
*]):
\
/
\
/([
\
*][
\
.][^
\
*]*|[^
\
*]*|[
\
*])
\
/
"
);
return
target
.
match
(
"
(http|https|[
\
*]):
\
/
\
/([
\
*][
\
.][^
\
*]*|[^
\
*]*|[
\
*])
\
/
"
);
}
}
/**
* If url pattern is valid save the data to the local storage and restart modify header
**/
function
save_data
()
function
save_data
()
{
{
if
(
!
isTargetValid
(
document
.
getElementById
(
'
targetPage
'
).
value
))
if
(
!
isTargetValid
(
document
.
getElementById
(
'
targetPage
'
).
value
))
{
{
alert
(
"
Url pattern is invalid
"
);
alert
(
"
Can not save :
Url pattern is invalid
"
);
return
;
return
;
}
}
localStorage
.
setItem
(
"
config
"
,
create_configuration_data
());
localStorage
.
setItem
(
"
config
"
,
create_configuration_data
());
browser
.
runtime
.
sendMessage
(
"
reload
"
);
browser
.
runtime
.
sendMessage
(
"
reload
"
);
}
}
/**
* If url pattern is valid save the data in a file
**/
function
export_data
()
function
export_data
()
{
{
if
(
!
isTargetValid
(
document
.
getElementById
(
'
targetPage
'
).
value
))
{
alert
(
"
Can not export : Url pattern is invalid
"
);
return
;
}
// Save in local storage
save_data
();
save_data
();
// Create file data
// Create file data
var
to_export
=
create_configuration_data
();
var
to_export
=
create_configuration_data
();
...
@@ -118,6 +138,11 @@ function export_data()
...
@@ -118,6 +138,11 @@ function export_data()
a
.
click
();
a
.
click
();
}
}
/**
* Choose a file and import data from the choosen file
*
**/
function
import_data
(
evt
)
function
import_data
(
evt
)
{
{
// create an input field in the iframe
// create an input field in the iframe
...
@@ -134,6 +159,13 @@ function import_data(evt)
...
@@ -134,6 +159,13 @@ function import_data(evt)
}
}
/**
* Import data from a file
*
* If format is not recognized , try modify header add-an file format
*
**/
function
readSingleFile
(
e
)
function
readSingleFile
(
e
)
{
{
var
file
=
e
.
target
.
files
[
0
];
var
file
=
e
.
target
.
files
[
0
];
...
@@ -195,7 +227,9 @@ function readSingleFile(e)
...
@@ -195,7 +227,9 @@ function readSingleFile(e)
}
}
/**
* Delete a configuration line on the UI
**/
function
delete_line
(
line_number_to_delete
)
function
delete_line
(
line_number_to_delete
)
{
{
if
(
line_number_to_delete
!=
line_number
)
if
(
line_number_to_delete
!=
line_number
)
...
@@ -215,7 +249,9 @@ function delete_line(line_number_to_delete)
...
@@ -215,7 +249,9 @@ function delete_line(line_number_to_delete)
line_number
--
;
line_number
--
;
}
}
/**
* Stop or Start modify header
**/
function
start_modify
()
function
start_modify
()
{
{
if
(
started
==
"
off
"
)
if
(
started
==
"
off
"
)
...
...
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