Skip to content

Commit

Permalink
Show cleaned javacsript-links in popup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Mar 14, 2020
1 parent c8349d8 commit c3df3de
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions addon/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
"Import rules": {
"message": "Import rules"
},
"Javascript link": {
"message": "Javascript link"
},
"Link Tracking": {
"message": "Link Tracking"
},
Expand Down
7 changes: 5 additions & 2 deletions addon/pages/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ body {
flex-wrap: wrap;
align-items: center;
}
#filter_actions {
font-size: .85em;
}
.filters input {
margin: 0 5px 0 15px;
margin: 0 2.5px 0 5px;
}
.filters label:last-child {
margin-right: 15px;
margin-right: 5px;
}
.help {
position: relative;
Expand Down
1 change: 1 addition & 0 deletions addon/pages/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h3 id="title"> &mdash;
<label><input type="checkbox" name="embed" checked="checked" /><span i18n_text="Embedded URL"></span></label>
<label><input type="checkbox" name="remove" checked="checked" /><span i18n_text="Params stripped"></span></label>
<label><input type="checkbox" name="rewrite" checked="checked" /><span i18n_text="Path rewritten"></span></label>
<label><input type="checkbox" name="javascript" checked="checked" /><span i18n_text="Javascript link"></span></label>
</p>

<div id="history"></div>
Expand Down
25 changes: 24 additions & 1 deletion addon/pages/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,24 @@ function add_option(orig, clean, classes)
option.classList.add(...classes);
option.onclick = set_selected

orig = new URL(orig)
let js_cleaned_link = extract_javascript_link(orig), prefix = null, suffix = null;
if (js_cleaned_link && js_cleaned_link !== orig)
{
let start = orig.indexOf(js_cleaned_link);
let end = start + js_cleaned_link.length;

if (start > 0)
prefix = orig.slice(0, start);

if (start !== -1 && end !== orig.length)
suffix = orig.slice(end);

orig = new URL(js_cleaned_link);
option.classList.add('javascript');
}
else
orig = new URL(orig);

clean = new URL(clean)

let origin_node = document.createElement('span');
Expand All @@ -102,6 +119,9 @@ function add_option(orig, clean, classes)
let rules = Rules.find(orig);
let actions_to_whitelist = {};

if (prefix !== null)
append_decorated(option, prefix, 'deleted')

append_decorated(option, orig.origin)

if (rules.whitelist_path)
Expand Down Expand Up @@ -257,6 +277,9 @@ function add_option(orig, clean, classes)
append_decorated(option, keyval, decorate)
}

if (suffix !== null)
append_decorated(option, suffix, 'deleted')

let clean_node = document.createElement('span');
clean_node.setAttribute('raw-url', clean.href);
clean_node.classList.add('cleaned');
Expand Down

0 comments on commit c3df3de

Please sign in to comment.