I am tying to make a bookmark that does something similar to this one on 9xbuddy, but I want it for the Cite This Page feature on Wikipedia. This is what I have:
javascript:(function(){ window.open('https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=/'+ document.location.href); })();
but if you were to try and use the thing, it almost works. The problem is the page ID. So what I'm wondering is, is it possible to make the bookmark fetch them or no?
Thanks in advance (also run the snippet below to easily test it; so you can see exactly what the result is when the bookmark is used).
$(".selectable").click(function() {
$(this).select();
});
$(document).ready(function () {
var selectcounter = 1;
$(".selectable").each(function() {
idja = "selectable" + selectcounter;
$(this).attr('id', idja);
$(this).attr('onclick', 'selectText("' + idja + '")');
selectcounter++;
});
});
function selectText(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
}
}
.selectable {
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
click below text to select it, then drag into bookmarks bar to add as bookmark
<p class="selectable">javascript:(function(){ window.open('https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=/'+ document.location.href); })();</p>
You can use this as bookmark:
javascript:(function(){ window.open('https://en.wikipedia.org/wiki/Special:CiteThisPage?page='+ document.location.href.substr(document.location.href.lastIndexOf('/') + 1)); })();