вторник, 8 декабря 2009 г.

opera проблема ebay

страницы cgi.ebay.com отображаются в опере с большим пустым пространством, что очень неприятно и неудобно.

Есть решение:
1. создать директорию Opera scripts
2. создать в этой директории файл ebay javascript.user.js
следующего содержания:



/* =====================================================================================================
EBay View Item Page Fix for Opera
=====================================================================================================

This is a fix for the excessive blank space that appears when viewing an eBay listing in Opera.

Installation instructions:

1) Create a new folder on your computer called "Opera scripts" (the name and location aren't important).
2) Open Notepad and copy and paste in this entire script.
3) Save the file as "EBay View Item Page Fix.user.js" in the folder you created above.
4) In Opera, select Tools > Preferences, then the Advanced tab, then Content. Click the "JavaScript
options..." button and check that the "User JavaScript files" setting is empty. Then use the Choose
button to select the folder you created above. Finally, OK back out of the preferences.
Note: if the "User JavaScript files" setting already has a folder set, then save the script into that
folder instead of creating a new one. Don't change the existing setting.
5) Restart Opera

=====================================================================================================*/

// ==UserScript==
// @include http://vi.ebaydesc.co.uk/*
// @include http://cgi.ebay.co.uk/*
// @include http://vi.ebaydesc.ie/*
// @include http://cgi.ebay.ie/*
// @include http://vi.ebaydesc.com/*
// @include http://cgi.ebay.com/*
// @include http://cgi.benl.ebay.be/*
// @include http://vi.benl.ebaydesc.be/*
// @include http://cgi.befr.ebay.be/*
// @include http://vi.befr.ebaydesc.be/*
// ==/UserScript==

(function () {

var DEBUG = false;

var SIG = "NBT_EBAY_OPERA_FIX";

//set size of element el
//size is a string with format "SIG:WIDTH:HEIGHT"
//return TRUE if size set, or FALSE if invalid el or invalid/zero size
function setSize (el, size, toplevel)
{
if (el && size && size.indexOf (SIG) == 0)
{
var a = size.split(":");

var s = a[0];
var w = a[1];
var h = a[2];

if (s == SIG && h > 0 && w > 0)
{
if (h < 100) h = 100; //minimum height, as a failsafe if (w > 200) //sanity check
{
if (toplevel && DEBUG) alert ("Resizing description to "+w+" (w) x "+h+" (h)");

el.style.height=h+"px";
el.style.width=w+"px";

return true;
}

}
}

return false;
}

//return the toplevel iframe, or null if it doesn't exist - called from the main page
function get_toplevel_iframe()
{
var div = document.getElementById('ngvi_desc_div');
return (div && div.firstChild) ? div.firstChild.firstChild : null;
}

//the structure of the page is like this:
// main window
// - iframe 1
// - iframe 2 (this iframe contains the actual description)
//the main window initiates the request by sending message 1 to iframe 1
//iframe 1 then forwards it as message 2 to iframe 2
//iframe 2 calculates the correct descr size, and sends the size in a message back to iframe 1
//iframe 1 resizes iframe 2 and returns the size message back to the main window
//the main window then resizes iframe 1

//this function initialises the resize process - called when the main window has loaded
function init_resize_request()
{
var ifrm = get_toplevel_iframe();

//send message "SIG:1" to iframe 1
if (ifrm && ifrm.contentWindow)
{
if (DEBUG) alert ("Message 1 sent");
ifrm.contentWindow.postMessage (SIG+":1", "*");
}
}

//this function receives the size message from iframe 1 and resizes the iframe
function main_window_message_receiver (msg)
{
if (DEBUG) alert ("Message 4 received");

var ifrm = get_toplevel_iframe();
if (!(ifrm && setSize (ifrm, msg.data, true)))
setTimeout (init_resize_request, 1000); //error, re-send request
}

//this function handles the size request sent to the 2 embedded iframes
function iframe_message_receiver (msg)
{
//check for message received at iframe 1 from main window
if (msg.data == SIG+":1")
{
if (DEBUG) alert ("Message 1 received");

var ifrm = document.getElementById('d');

//send message "SIG:2" to iframe 2
if (ifrm && ifrm.contentWindow)
{
if (DEBUG) alert ("Message 2 sent");
ifrm.contentWindow.postMessage (SIG+":2", "*");
}
}

//check for message received at iframe 2 from iframe 1
else if (msg.data == SIG+":2")
{
if (DEBUG) alert ("Message 2 received");

//this code runs in iframe 2, the one that actually contains the description...
//calculate the description w & h, and post it back to the parent

//calculate content height by appending a div to the body and finding its offset
var d=document.createElement("div");
document.body.appendChild(d);

var h=d.offsetTop;
var w=document.body.scrollWidth;

document.body.removeChild(d);

if (h > 0) h += 10;
if (w > 0) w += 10;

//post width and height message back to the parent
if (DEBUG) alert ("Message 3 sent");
parent.postMessage (SIG+":"+w+":"+h, "*");
}

else
{
//message received at iframe 1 from iframe 2
//set iframe 2 size and pass the message back to the main window
if (DEBUG) alert ("Message 3 received");

if (setSize (document.getElementById('d'), msg.data, false))
{
if (DEBUG) alert ("Message 4 sent");
parent.postMessage (msg.data, "*");
}
}
}

//check if running in main window
if (self == top && document.getElementById("vi-container"))
{
if (DEBUG) alert ("At start of Opera eBay page fix");

//this removes white space below the page footer
if (document.getElementById("vi-bottom"))
document.getElementById("vi-bottom").style.overflow="hidden";

//set message receiver
window.addEventListener("message", main_window_message_receiver, false);

//initiate message request
setTimeout (init_resize_request, 1000);
}

//check if running in embedded iframe
else if (self != top && document.location .href.indexOf("ebaydesc") != -1)
{
window.addEventListener("message", iframe_message_receiver, false);
}

})();
3. в опере открыть cgi.ebay.com
4. правой кнопкой на странице, выбрать настройки для сайта
5. на вкладке скрипты в поле папка пользовательских файлов javascript указать созданную в пункте 1 директорию
6. перезапустить Opera

Еще можно попробывать:
находясь на странице cgi.ebay.com включить подгонку по ширине
Вид -> подогнать по шерине
а еще встречал советы, не принимать cookie от ebay, незнаю насоклько это действенно.

Комментариев нет: