要使用CSS访问属性访问链接,它不工作,是否有任何方法或解决方法来获取访问过的链接?如何使用JavaScript或jQuery或通过任何其他技术访问访问过的链接历史
0
A
回答
0
0
enter code here
它不是由JavaScript的支持,我也试图找到方法收集a:访问链接数据以隐藏访问的节点。
一些参考: 隐私和:访问选择器 - CSS | MDN
如果你只关心样式,你应该可以通过CSS实现它,但通过屏幕上显示的内容应该是观察它被访问的唯一方法。
我在Greasemonkey的userscript中这样做,让那些没有:visited风格的网站显示那些已经访问过的链接。
// ==UserScript==
// @description ADD a:visited for CSS
// @include *annalscts.com*
// @include *thejns.org*
// @include *turkishneurosurgery.org.tr*
// @include *nature.com*
// @include *academic.oup.com*
// @include *sagepub.com*
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle('a:visited {color:#EE5665 !important}');
为了收集数据,以本地我使用的Greasemonkey API
GM_setValue
GM_getValue
我只是看着教程在Youtube上的API,并尝试写入到userscript
的Greasemonkey API:值只是在Youtube上搜索这个标题。
书面指导:http://nulleffort.com/greasemonkey-api-values/
Greasemonkey的文档:https://wiki.greasespot.net/Greasemonkey_Manual:API
我userscript的某些部分
//Firstly, var the ordinary variable preVisitedLinks and assigning to memory variable visitedLinks (At first the value should be undefined)
var preVisitedLinks = GM_getValue("visitedLinks");
unsafeWindow.aclick = function(tlink){
window.open(tlink, '_blank', 'toolbar=yes,scrollbars=yes,resizable=yes,top=10,left=10,width=10,height=10'); // click a button added and get the link visited in my script
//If the ordinary variable preVisitedLinks is undefined (First time running the script)
if(preVisitedLinks.includes('undefined')){
GM_setValue('preVisitedLinks', '|' + tlink.replace('http://paper.pubmed.cn/',''));
}
//If the ordinary variable preVisitedLinks is not undefined, continue to add each new string collect
else{
GM_setValue('preVisitedLinks', preVisitedLinks + '|' + tlink.replace('http://paper.pubmed.cn/',''));
}
//The ordinary variable preVisitedLinks assigning to memory variable visitedLinks value. The magic is the variable name the same.
preVisitedLinks = GM_getValue("preVisitedLinks");
if(preVisitedLinks.length > 27500){
preVisitedLinks = preVisitedLinks.substr(preVisitedLinks.length - 27500);
}
//The memory variable visitedLinks value assigning to the ordinary variable preVisitedLinks value
GM_setValue('visitedLinks',preVisitedLinks);
console.info(preVisitedLinks);
};
而在一些地方,我使用字符串来检测访问过的链接代码
if(preVisitedLinks.includes(trs[i].querySelectorAll('li')[0].querySelector('a').href.replace('http://xxx.xxxx.com/',''))){
trs[i].remove();
}
0
你可以创建你的自己的历史只是使用localStorage和添加锚的历史,他们被访问或点击了多少次,可能是这段代码片段不会在这里工作,你可以通过这段代码到你的文件或提琴它工作正常,历史记录保存在本地存储, 每次你点击锚点数量都在增加。
$('a').on("click",function(){
var anchorhistory=localStorage.getItem($(this).attr("id"));
if(anchorhistory){
anchorhistory=parseInt(anchorhistory)+1;
localStorage.setItem($(this).attr("id"), anchorhistory);
alert($(this).attr("id")+" is clicked "+anchorhistory+" Times");
}
else{
anchorhistory=1;
localStorage.setItem($(this).attr("id"), anchorhistory);
alert($(this).attr("id")+" is clicked "+anchorhistory+" Times");
}
})
ul a{
cursor:pointer;
color:blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li><a id='anchor1'>anchor1</a></li>
<li><a id='anchor2'>anchor2</a></li>
<li><a id='anchor3'>anchor3</a></li>
<li><a id='anchor4'>anchor4</a></li>
</ul>
相关问题
- 1. Longpoll技术或任何其他方法
- 2. 如何访问通过JavaScript
- 3. 如何通过jquery访问javascript属性?
- 4. 如何通过Hub访问MenuFlyout或使其不会消失
- 5. 如何使用混合技术访问本机日历
- 6. 如何通过编程访问iphone浏览器历史记录
- 7. 如何访问通过JavaScript点击一个HTML链接的SDcard ..?
- 8. 如何使用JavaScript获取访问过的链接CSS样式
- 9. 通过Javascript或jQuery从传入访问者(推荐人)提取链接
- 10. 通过DOM遍历jQuery直接访问javascript对象
- 11. 通过Javascript访问日历控件
- 12. 通过访问链接调用函数
- 13. 通过replaceDialog或任何其他方式
- 14. 访问轨私人/保护方法通过JavaScript或jQuery的
- 15. Python - 通过其他值访问Json值
- 16. 通过其他类访问表单
- 17. 通过bitbucket中的链接访问
- 18. 如何访问工作项链接和附件历史记录
- 19. 如何使用javascript,jquery或其他javascript框架过滤数据?
- 20. 如何通过javascript访问JSON元素?
- 21. 如何通过javascript访问processing.js变量
- 22. 如何通过javascript访问JSON数据
- 23. 如何通过javaScript访问类名
- 24. 如何通过javascript访问Telerik HtmlAttributes值?
- 25. 访问SVG使用子元素/链接通过JavaScript
- 26. 这些JavaScript链接如何通过Selenium或BeautifulSoup遍历?
- 27. 访问VI历史
- 28. 如何通过jQuery访问会话ID
- 29. 如何获取访问过的网站历史记录(android)?
- 30. 如何通过Android访问SSL连接?
即使你不能访问用户的历史,你只能检查什么是最后一个页面的用户通过'document.referrer'访问,使用JavaScript。 – Nevershowmyface