here is a greasemoneky script that popups link content to a iframe window. I know there is a method to remove specific div or to remove all except the one I want:
$("preview").contents().find("*:not(#content container)").remove();
Here I want just content container to show in iframe. But I don't know how to call this from greasemonkey. The iframe windows is on same domain. Here's the script itself. It's not mine, just found it on the net and trying to make it useful in my case
// ==UserScript==
// @name Hover Preview
// @namespace HP
// @description Pops up a floating div when you hover over a link, containing the target page!
// @include *
// @grant GM_addStyle
// @version 0.0.1.20150213035046
// ==/UserScript==
// TODO:
// Don't act if the target is a file-type. i.e. we don't want to be prompted
// to save a zip file just because we hovered on it.
// KNOWN UNFIXABLE BUG:
// Damnit some pages break out of the iframe! Don't try to use this on
// StackOverflow links!
// if (window.document != document) {
// return; // Don't run in iframes
// }
// Quite nice on apache file listings of .jpegs, but a bit slow. Ideally pre-load hoverable images?
// Could be a bit heavy. It depends on the page...
// A different bookmarklet to turn all "links to images" into "images" would be nice. :)
var focusReactionTime = 300;
var unfocusReactionTime = 300;
var focus = undefined;
var lastFocus = undefined;
var timer = null;
var myPopup;
var myFrame;
var isOverPopup = false;
function checkFocus() {
if (focus) {
showPreviewWindow(focus);
}
}
function eekAMouse(evt) {
if (evt.currentTarget.tagName !== "A") {
return;
}
if (!focus) {
focus = evt.currentTarget;
if (myFrame && focus.href && myFrame.href == focus.href) {
showPreviewWindow(focus,evt);
} else {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(checkFocus,focusReactionTime);
}
} else {
window.status = "Already focused on a link wtf!";
}
}
function phewMouseGone(evt) {
if (evt.currentTarget.tagName !== "A") {
return;
}
focus = undefined;
if (timer) {
clearTimeout(timer);
}
// TESTING: Don't hide the popup if mouse is currently over the popup!
timer = setTimeout(clearPopup,unfocusReactionTime);
}
function clearPopup(e) {
if (isOverPopup || focus)
return;
if (myPopup) {
myPopup.style.display = 'none';
}
}
// DONE: If the user clicks a link, this isn't really a hover, so we should not
// activate and just let the user's click be processed!
function aClick(evt) {
focus = undefined;
}
function createPopup() {
// Create frame
myPopup = document.createElement('DIV');
/** Seems style does not work for Konqueror this way. **/
myPopup.innerHTML =
"<STYLE type='text/css'> iframe.preview { color: #ff8822; background-color: #ff0000; margin: 0px; padding: 2px; border: 2px solid white; text-align: center; } </STYLE>"
+
"<IFRAME class='preview' width='"+(window.innerWidth*0.35)+"' height='"+(window.innerHeight*0.35)+"' src='about:blank' onload='doSomething()'></IFRAME>";
myPopup.addEventListener("mouseover", function(evt) { isOverPopup=true; }, false);
myPopup.addEventListener("mouseout", function(evt) { isOverPopup=false; setTimeout(clearPopup,unfocusReactionTime); }, false);
document.documentElement.appendChild(myPopup);
myPopup.style.position = "fixed";
myPopup.style.right = "12px";
myPopup.style.bottom = "12px";
myPopup.style.zIndex = "10000";
myFrame = myPopup.getElementsByTagName('IFRAME')[0];
}
function doSomething(){
}
function showPreviewWindow(link,evt) {
if (!myFrame) {
createPopup();
}
myPopup.style.display = '';
if (!myFrame.src || myFrame.src != link.href)
myFrame.src = link.href;
$("preview").contents().find("*:not(#adPage__content container_25)").remove();
}
function init() {
for (var i=0;i<document.links.length;i++) {
var link = document.links[i];
/** The new way: **/
link.addEventListener("mouseover", eekAMouse, false);
link.addEventListener("mouseout", phewMouseGone, false);
link.addEventListener("click", aClick, false);
}
}
init();