我列出了使用document.links
(带有用户名)的某些网站底部的所有链接。
访问过的和未访问过的url-s一起出现。我可以为它们设置不同的颜色,这样很容易看出哪些链接是新的,哪些链接是我已经访问过的。但我希望看到仅新链接。
有没有办法让a:link
仅列出未访问的(新的)visibility:hidden;
)链接?
(如果不可能,那我怎么能隐藏访问过的链接?我在display:none;
上尝试了a:visited
和//Show Histogram
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
CIImage *ciImage = [[CIImage alloc] initWithCVPixelBuffer:pixelBuffer options:(__bridge NSDictionary *)attachments];
NSUInteger count = 256;
count = count <= 256 ? count : 256;
count = count >= 1 ? count : 1;
NSDictionary *params = @{kCIInputImageKey: ciImage,
kCIInputExtentKey: [CIVector vectorWithCGRect:[ciImage extent]],
@"inputCount": @(256), @"inputScale": @(200)
};
CIFilter *filter = [CIFilter filterWithName:@"CIAreaHistogram"
withInputParameters:params];
CIImage *outImage = [filter outputImage];
//---------------------------------------------
CIContext *context = [CIContext contextWithOptions:nil];
NSDictionary *params2 = @{
kCIInputImageKey: outImage
};
CIFilter *filter2 = [CIFilter filterWithName:@"CIHistogramDisplayFilter"
withInputParameters:params2];
CIImage *outputImage = [filter2 outputImage];
CGRect outExtent = [outputImage extent];
CGImageRef cgImage = [context createCGImage:outputImage
fromRect:outExtent];
UIImage *outImage2 = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
// resize
UIImage *resized = [self resizeImage:outImage2
withQuality:kCGInterpolationNone
rate:2.5];
//Remove the default grey background
resized = [self removeColorFromImage:resized grayLevel:137];
dispatch_async(dispatch_get_main_queue(),
^{
self.histogramView.image = resized;
});
,但没有工作。发现它是{{{ 3}}但我不想触摸原始页面上的链接,只能链接到我的链接集合中。“
答案 0 :(得分:1)
可能不可能
我不完全确定due to the security issue similar to the one you mentioned in this similar article会导致$('.scIcon').data('itemid')
选择器受到严格限制的可能性如何,这使得在现代浏览器中几乎不可能进行编程访问。
通过:visited
我想you could use a workaround similar to the one mentioned in this blog post,它使用localStorage明确存储点击的链接并保留“访问”属性,以便您可以识别那些已被触摸的链接:
localStorage
这种方法会将“访问”类附加到元素中,并允许您使用纯CSS方法显式删除它们:
function check_visited_links(){
// Access all of the elements that have been visited (from local storage)
var visited_links = JSON.parse(localStorage.getItem('visited_links')) || [];
// Iterate through your links
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
var that = links[i];
// When the link is clicked, store a reference in localStorage to it
that.onclick = function () {
var clicked_url = this.href;
if (visited_links.indexOf(clicked_url)==-1) {
visited_links.push(clicked_url);
localStorage.setItem('visited_links', JSON.stringify(visited_links));
}
}
// Indicate the link was visited by setting it's class
if (visited_links.indexOf(that.href)!== -1) {
that.className += ' visited';
}
}
}
或者使用类似于您最初使用的Javascript技术:
a.visited { display: none; }
使用document.querySelectorAll('a.visited');
技术的示例
您可以see an example that uses the localStorage
technique here(仅在按下每个按钮后重新加载)以及下面的输出示例: