/*
* @title jump with partial modification (sample)
* @description jump with partial modification (sample)
* @include http://*, https://*
* @license MIT http://opensource.org/licenses/MIT
* @javascript_url
*/
// answer of http://q.hatena.ne.jp/1491958499
((url) => {
const d_ = document;
const variable = "@@@";
const width = 60;
const c_style_ = {
backgroundColor: "green",
color: "white",
position: "absolute",
width: (width + 20) + "ex",
};
const i_style_ = {
fontFamily: "monospace",
fontSize: "10.5pt",
width: width + "ex",
margin: "2em auto",
display: "block",
border: "none",
padding: "2px 1px",
};
// container
const c_ = d_.body.appendChild(Object.assign(d_.createElement("div"), {
id: "a-kuma3",
}));
Object.assign(c_.style, c_style_);
// input
const i_ = c_.appendChild(Object.assign(d_.createElement("input"), {
type: "text",
value: url,
onkeydown: function(ev) {
switch (ev.keyCode) {
case 13: // Enter
location.href = this.value;
this.style.display = "none";
const m_ = c_.appendChild(Object.assign(d_.createElement("div"), {
innerHTML: "Now Loading ...",
}));
Object.assign(m_.style, i_style_);
break;
case 27: // ESC
c_.parentNode.removeChild(c_);
break;
}
},
}));
Object.assign(i_.style, i_style_);
// position
const h_ = d_.documentElement;
Object.assign(c_.style, {
top: (h_.scrollTop + h_.clientHeight / 2 - c_.clientHeight / 2) + "px",
left: (h_.scrollLeft + h_.clientWidth / 2 - c_.clientWidth / 2) + "px",
});
// select variable part
i_.select();
i_.selectionStart = url.indexOf(variable);
i_.selectionEnd = i_.selectionStart + variable.length;
})("http://q.hatena.ne.jp/@@@/watchlist");