您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
One click to copy the bib information of each google scholar entry. The bib information will be automatically copied into the clipboard.
当前为
// ==UserScript== // @name Google Scholar Oneclick Copy Bib // @namespace http://tampermonkey.net/ // @version 0.5 // @description One click to copy the bib information of each google scholar entry. The bib information will be automatically copied into the clipboard. // @author Maple // @include https://scholar.google.com* // @include https://scholar.google* // @include https://scholar.googleusercontent.com* // @icon https://icon-icons.com/downloadimage.php?id=130918&root=2108/ICO/64/&file=google_scholar_icon_130918.ico // @grant none // @license MIT // ==/UserScript== //Sleep function const sleep = (milliseconds) => { return new Promise(resolve => setTimeout(resolve, milliseconds)) } async function openbib(event){ var abib = (event.target || event.srcElement); abib.parentElement.querySelector("a.gs_or_cit.gs_nph").click(); while(1){ try{ await sleep(100); document.querySelector("a.gs_citi").click(); break; }catch(e){ } } } var items = document.querySelectorAll("div.gs_ri div.gs_fl"); for (var item of items){ var bib = document.createElement('a'); bib.innerHTML = "Copy Bib" bib.setAttribute ('class', 'abib'); bib.setAttribute ('style', 'display:inline; color: #180EA4 !important;'); bib.setAttribute ('href', '#'); //bib.setAttribute ('onclick', 'openbib(this);'); bib.addEventListener ( "click", openbib, false ); item.appendChild (bib); } //============================================================ /*const copyToClipboard = str => { const el = document.createElement('textarea'); el.value = str; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); el.focus(); el.select(); console.log(el); //var result = document.execCommand('copy'); console.log(result); document.body.removeChild(el); };*/ function fallbackCopyTextToClipboard(text) { var textArea = document.createElement("textarea"); textArea.value = text; // Avoid scrolling to bottom textArea.style.top = "0"; textArea.style.left = "0"; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; console.log('Fallback: Copying text command was ' + msg); } catch (err) { console.error('Fallback: Oops, unable to copy', err); } document.body.removeChild(textArea); } function copyToClipboard(text) { if (!navigator.clipboard) { fallbackCopyTextToClipboard(text); return; } navigator.clipboard.writeText(text).then(function() { console.log('Async: Copying to clipboard was successful!'); }, function(err) { console.error('Async: Could not copy text: ', err); }); } if(window.location.href.includes("googleusercontent")){ //document.body.innerText //console.log(document.body.innerText) copyToClipboard(document.body.innerText); window.history.go(-2); }