维基百科快速引用页面书签
Wikipedia quick cite page bookmark
我想制作一个书签来做类似的事情 to this one on 9xbuddy,但我想要它用于维基百科上的“引用此页”功能。这是我的:
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/ 替换为空字符串:
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\//, '')); })();
我想制作一个书签来做类似的事情 to this one on 9xbuddy,但我想要它用于维基百科上的“引用此页”功能。这是我的:
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/ 替换为空字符串:
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\//, '')); })();