脸书情绪
此代码来自 Facebook 聊天表情栏 Grease Monkey UserScript
ImagesURL = HttpsOn?'https://s-static.ak.fbcdn.net/images/':'http://static.ak.fbcdn.net/images/';
emotsInfo = [':)', ':(', ':p', ':D', ':o', ';)', '8)', '8|', '>:(', ':/', ':\'(', '3:)', 'O:)', ':*', '<3', '^_^', '-_-', 'o.O', '>:O', ':v', ':3'];
for(i=0;i<emotsInfo.length;i+=1) {
var fEmotsDom = document.createElement('img');
fEmotsDom.setAttribute('alt',emotsInfo[i]);
fEmotsDom.setAttribute('style','cursor: pointer; background-position: -'+ 16*i +'px 0px;');
fEmotsDom.setAttribute('src',ImagesURL + 'blank.gif');
fEmotsDom.setAttribute('class','emote_img');
fEmotsListDom.appendChild(fEmotsDom);
}
此代码从 Facebook 服务器带来 Facebook 表情
我正在编写 WPF 代码,除了从空白.gif 中获取情感之外,我了解所有代码过程
C# 代码
const string EmotionsResources = "http://static.ak.fbcdn.net/images/";
private Image Emoticons ( string E )
{
return ( new Image ( ) { Source = new BitmapImage ( new Uri ( EmotionsResources + E ) ) } );
}
如果您尝试获取任何 Facebook 聊天情绪的来源..您将得到 [ http://static.ak.fbcdn.net/images/blank.gif ] 这段代码如何从此链接检索情绪?
This code is from Facebook Chat Emoticons Bar Grease Monkey UserScript
ImagesURL = HttpsOn?'https://s-static.ak.fbcdn.net/images/':'http://static.ak.fbcdn.net/images/';
emotsInfo = [':)', ':(', ':p', ':D', ':o', ';)', '8)', '8|', '>:(', ':/', ':\'(', '3:)', 'O:)', ':*', '<3', '^_^', '-_-', 'o.O', '>:O', ':v', ':3'];
for(i=0;i<emotsInfo.length;i+=1) {
var fEmotsDom = document.createElement('img');
fEmotsDom.setAttribute('alt',emotsInfo[i]);
fEmotsDom.setAttribute('style','cursor: pointer; background-position: -'+ 16*i +'px 0px;');
fEmotsDom.setAttribute('src',ImagesURL + 'blank.gif');
fEmotsDom.setAttribute('class','emote_img');
fEmotsListDom.appendChild(fEmotsDom);
}
This code brings Facebook emotions from Facebook server
I'm coding a WPF , I understand all code procedures except getting the emotion from blank.gif
C# Code
const string EmotionsResources = "http://static.ak.fbcdn.net/images/";
private Image Emoticons ( string E )
{
return ( new Image ( ) { Source = new BitmapImage ( new Uri ( EmotionsResources + E ) ) } );
}
if you try to get source of any of Facebook chat emotions .. you will get [ http://static.ak.fbcdn.net/images/blank.gif ]
this code retrieve emotions from this link HOW ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里猜测,但我认为该类会触发一种检查替代文本的样式。 (一旦你划掉了所有不可能的答案,这是唯一有效的答案。每次迭代中唯一改变的是替代文本,所以这一定是触发它的内容。CSS类选择器可以处理属性值)
并且在换句话说——你被困住了。
编辑
所以我很感兴趣,所以我开始更深入地挖掘:
图像上的CSS样式包含以下CSS规则:
第一个由脚本设置,第二个来自CSS文件。
所以。实际图像可以在该 png 文件中找到,即:
http://static.ak.fbcdn.net/rsrc.php/v1/zC/r/eKCEtE1PXyK.png:
(很高兴知道你可以在 Facebook 中使用这么多表情符号!:-)
,你会在一张图像中看到所有图像(这样做是为了节省带宽)
由于图像尺寸为16*16,因此一次仅显示一张图像。
背景位置的东西负责移动图像,以便每次从大图像中显示不同的图标。
因此,要在 C# 中获取图像,您将执行以下操作:
您可以裁剪它,或者使用完全相同的技巧(在我看来这是更好的方法),如下所示:
I'm guessing here, but I think that the class triggers a style that checks the alt text. (that's the only valid answer once you cross-off all the impossible answers.. the only thing that changes in each iteration is the alt text so that must be what's triggering it. and a css class selector can work on attribute values)
and in other words - you're stuck.
Edit
So i was intrigued so i started to dig a bit deeper:
css style on the image has the following css rules in it:
the first one is set by the script, and the second comes from the CSS file.
so. the actual images are found in that png file, which is:
http://static.ak.fbcdn.net/rsrc.php/v1/zC/r/eKCEtE1PXyK.png:
(cool to know u can use so many emoticons in fb! :-)
and you'll see ALL of the images in one image (it's done to preserve bandwidth)
since the image size is 16*16, it only shows ONE image at a time.
the background-position thingie is in charge of shifting the image, so that each time a different icon is shown from the big image.
So to get the image in C# you'll do the following:
you can either crop it, or use the exact same trick (which is better IMO), like this: