Skip to content

Commit

Permalink
Add a test page
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Jul 22, 2018
1 parent 0f932c1 commit 05c8107
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>Test cleaning links</title>

<!-- Mock browser object so cleanLink can be loaded -->
<script>
var browser = {
runtime: Object.assign({getManifest: () => ({
"name": "Clean Links",
"description": "Converts obfuscated/nested links to genuine clean links",
"author": "Cimbali (maintainer), \nDiego Casorran (creator), \nEduard Braun (German translation), \nSimon Chan (Chinese and Taiwanese translations)",
"version": "3.0.3",
"homepage_url": "https://github.com/Cimbali/CleanLinks",
})
}),
storage: {local: {get: () => {}}},
i18n: {getMessage: () => "string"}
}
</script>

<!-- Embed the actual cleanLink script -->
<script src="https://cdn.rawgit.com/Cimbali/CleanLinks/master/addon/cleanlink.js"></script>

<!-- Inner workings of this page -->
<script>
function addToList(dirty, clean)
{
var l = document.querySelector('ul#clean_history');

l.insertBefore(document.createElement('li'), l.children[0]);
l.children[0].textContent = ' ';

l.insertBefore(document.createElement('li'), l.children[0]);
l.children[0].textContent = clean;
l.children[0].className = 'cleaned'

l.insertBefore(document.createElement('li'), l.children[0]);
l.children[0].textContent = dirty;
}

function testCleaning()
{
var link = document.querySelector('#paste_link input').value;
if (link) addToList(link, cleanLink(link))
}

window.onload = () =>
{
document.querySelector('#paste_link button').onclick = testCleaning
}
</script>

<!-- Styling for the page -->
<style>
p#paste_link {
width: 100%;
display: inline-flex;
align-items: baseline;
}
p#paste_link input {
width: 5em;
margin: 0 1em;
flex-grow: 1;
}
ul#clean_history {
list-style: none;
}
ul#clean_history li.cleaned:before{
content: '→';
position: relative;
left: -5px;
padding-bottom: 10px;
}
</style>
</head>

<body>
<p id="paste_link">Link:&nbsp;<input type="text" />&nbsp;<button>Clean it!</button></p>
<ul id="clean_history"></ul>
</body>

</html>

0 comments on commit 05c8107

Please sign in to comment.