Wikipedia快速引用页面标记



我正在绑上一个书签,该书签在9xbuddy上做类似的书签,但我希望它为Wikipedia上的此页面功能而言。这就是我所拥有的:

javascript:(function(){ window.open('https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=/'+ document.location.href); })();

但是,如果您要尝试使用它,它几乎可以起作用。问题是页面ID。所以我想知道的是,可以使书签获取它们还是没有?

预先感谢(也将下面的摘要轻松测试;因此,您可以准确查看使用书签时的结果)。

$(".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>

您可以将其用作书签:

javascript:(function(){ window.open('https://en.wikipedia.org/wiki/Special:CiteThisPage?page='+ document.location.href.substr(document.location.href.lastIndexOf('/') + 1)); })();

使用路径名而不是href,然后用空字符串替换/wiki/wiki:

document.location.pathname.replace(/^/wiki//, ''))

完整书签:

javascript:(function(){ window.open('https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page='+ document.location.pathname.replace(/^/wiki//, '')); })();

最新更新