Skip to content

Commit

Permalink
first version that needs to be a userscript
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Dvorak committed Nov 7, 2014
1 parent 0e47541 commit 99520a0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
73 changes: 73 additions & 0 deletions se-chat-iframe-popup.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ==UserScript==
// @name Stack Exchange hover popup
// @description Shows a popup with a SE question when a link to the question is hovered in the chat
// @require http://cherne.net/brian/resources/jquery.hoverIntent.minified.js
// @include http://*stackexchange.com/*
// @include http://*stackoverflow.com/*
// @include http://*mathoverflow.com/*
// @include http://*serverfault.com/*
// @include http://*superuser.com/*
// @include http://*stackapps.com/*
// @include http://*askubuntu.com/*
// @version 2.2
// ==/UserScript==
$(function(){
var currentFrame = null;
$("body").click(function(){
if(currentFrame) currentFrame.parentNode.removeChild(currentFrame);
currentFrame = null;
});
$("#chat").hoverIntent({
selector: ".content a",
out: function(){console.log("out");},
over: function(event){
console.log("in %o", this);
if(isSeDomain(this.host)){
console.log("domain matches");
var overlay = document.createElement("div");
overlay.style.background = "rgba(0, 0, 0, 0.5)";
overlay.style.position = "fixed";
overlay.style.top = 0;
overlay.style.left = 0;
overlay.style.right = 0;
overlay.style.bottom = 0;

var frame = document.createElement("iframe");

currentFrame = document.createElement("div");
currentFrame.style.margin = 5;
currentFrame.style.border = "3px solid black";
currentFrame.style.borderRadius = 5;
currentFrame.style.padding = 10;
currentFrame.appendChild(overlay);
currentFrame.appendChild(frame);
console.log("%o appended", currentFrame);

GM_xmlhttpRequest({
url: link.href,
onload: function(response){
frame.document.documentElement.innerHTML = response.data;
document.body.appendChild(currentFrame);
}
});
}
}
});
function isSeDomain(host){
var hosts = ["stackexchange.com",
"stackoverflow.com",
"mathoverflow.com",
"serverfault.com",
"superuser.com",
"stackapps.com",
"askubuntu.com"]
host = host.match(/\w+\.\w+$/)[0];
return !!~hosts.indexOf(host);
}
}());

/*
var s = document.createElement("script");
s.src = "http://cherne.net/brian/resources/jquery.hoverIntent.minified.js";
document.head.appendChild(s);
*/
3 changes: 2 additions & 1 deletion so-post-monitor.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @include http://*superuser.com/*
// @include http://*stackapps.com/*
// @include http://*askubuntu.com/*
// @version 2.1
// @version 2.2
// ==/UserScript==

(function () {
Expand Down Expand Up @@ -175,6 +175,7 @@
});

setInterval(UpdateTask.updateAll, UPDATE_TIMEOUT);
$(document).on("visibilitychange", UpdateTask.updateAll);

/// timer functions

Expand Down

0 comments on commit 99520a0

Please sign in to comment.