transform unhide_func from macro to included html
This commit is contained in:
parent
eb13d4f4a0
commit
354a0a958a
28
template/hide.html
Normal file
28
template/hide.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<script>
|
||||
function unhide(seed, arr) {
|
||||
seed %= 1000000007;
|
||||
const str_arr = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
str_arr.push((((arr[i] - seed) % 256) + 256) % 256)
|
||||
seed = seed * seed % 1000000007;
|
||||
}
|
||||
|
||||
const ui8_arr = new Uint8Array(str_arr);
|
||||
const str = new TextDecoder().decode(ui8_arr);
|
||||
return str;
|
||||
}
|
||||
|
||||
function unhide_permalink() {
|
||||
let anchors = document.querySelectorAll("a[hidden_permalink][seed]")
|
||||
for (let anchor of anchors) {
|
||||
let arr = new Array();
|
||||
for (let n of anchor.getAttribute("hidden_permalink").split(",")) {
|
||||
arr.push(Number(n));
|
||||
};
|
||||
|
||||
let seed = Number(anchor.getAttribute("seed"))
|
||||
|
||||
anchor.href = unhide(seed, arr);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,37 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
{% macro unhide_func() %}
|
||||
<script>
|
||||
function unhide(seed, arr) {
|
||||
seed %= 1000000007;
|
||||
const str_arr = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
str_arr.push((((arr[i] - seed) % 256) + 256) % 256)
|
||||
seed = seed * seed % 1000000007;
|
||||
}
|
||||
|
||||
const ui8_arr = new Uint8Array(str_arr);
|
||||
const str = new TextDecoder().decode(ui8_arr);
|
||||
return str;
|
||||
}
|
||||
|
||||
function unhide_permalink() {
|
||||
let anchors = document.querySelectorAll("a[hidden_permalink][seed]")
|
||||
for (let anchor of anchors) {
|
||||
let arr = new Array();
|
||||
for (let n of anchor.getAttribute("hidden_permalink").split(",")) {
|
||||
arr.push(Number(n));
|
||||
};
|
||||
|
||||
let seed = Number(anchor.getAttribute("seed"))
|
||||
|
||||
anchor.href = unhide(seed, arr);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro render_item(item) %}
|
||||
|
||||
{% set class_str = "item" %}
|
||||
|
@ -84,7 +52,7 @@
|
|||
<meta name="viewport" content="width=device-width,minimum-scale=1">
|
||||
<link ref="canonical" href="{{canonical_link}}" />
|
||||
|
||||
{{ unhide_func() }}
|
||||
{% include "hide.html" %}
|
||||
</head>
|
||||
|
||||
<style>{% include "reset.css" %}</style>
|
||||
|
|
Loading…
Reference in a new issue