アクセス許可ベースの回避策をコード化しましたが、ユーザーがクリックしたときにアクセス許可を得るためにユーザーにバグを報告する必要があるため、理想からはほど遠いと思いますが、何もないよりはましです。
Google が不要な Cookie をドロップしないようにする方法が必要です。私の意見では、非常に多くの Cookie または Cookie を使用してユーザーを追跡する必要はまったくありません。
このコードは、ユーザーにリンクをクリックさせます。クリックすると、ボタンを表示するかどうか、およびその決定の結果は何かを尋ねられます。
私のコード例: http://jsfiddle.net/CADjN/3/
ライブデモ https://www.ortho.nl/orthomoleculaire-bibliotheek/artikel/8091/Langer-leven-met-vitamine-D
<script type="text/javascript">
// Function to set the cookie plusone.
function setCookie()
{
domain = "www.mysite.com";
c_name="plusone";
value="yes";
var exdate=new Date();
exdate.setDate(exdate.getDate() + 365);
var c_value=escape(value) + "; expires="+exdate.toUTCString()+';domain='+domain+';path=/';
document.cookie=c_name + "=" + c_value;
}
// Function to see if our plusone cookie exists and has value yes
// Returns true when the cookie is set, false if isn't set.
function getCookie()
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x.indexOf("plusone") != -1)
{
if(unescape(y)=="yes")
{
return true;
}
else
{
return false;
}
}
}
}
// Load the plusone module but first ask permission
function loadplusone(thelink)
{
// Cookie hasn't been set
if(!getCookie())
{
// Get permission
if(window.confirm("If you wish to 'plusone' this page we need to load a special button from Google.com.\n\nWith this button Google will place some cookies on your computer. Google uses these cookies for statistics and maintaing your login status if you have logged in with Google.\n\nDo you consent to loading the button and the placement of cookies by Google?\n\nIf you agree this website will place a cookie with a year lifetime on your computer to remember this and the plusone button will be loaded on every page where the plusone button is present on this site."))
{
// set cookie, load button
setCookie();
var jsnode = document.createElement('script');
jsnode.setAttribute('type','text/javascript');
jsnode.setAttribute('src','https://apis.google.com/js/plusone.js');
document.getElementsByTagName('head')[0].appendChild(jsnode);
document.getElementById(thelink).innerHTML = '';
}
}
// cookie has already been set, just load button.
else
{
var jsnode = document.createElement('script');
jsnode.setAttribute('type','text/javascript');
jsnode.setAttribute('src','https://apis.google.com/js/plusone.js');
document.getElementsByTagName('head')[0].appendChild(jsnode);
document.getElementById(thelink).innerHTML = '';
}
}
</script>
<!-- Where the plusone button should go this piece of code should be placed -->
<a id="plus1" href="javascript:loadplusone('plus1')">Show Google +1</a><g:plusone></g:plusone>
<!-- This should be placed below the above code or in the onload event of the document -->
<script type="text/javascript">
if(getCookie())
{
var jsnode = document.createElement('script');
jsnode.setAttribute('type','text/javascript');
jsnode.setAttribute('src','https://apis.google.com/js/plusone.js');
document.getElementsByTagName('head')[0].appendChild(jsnode);
document.getElementById('plus1').innerHTML = '';
}
</script>