Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing dependency on Ruby #39

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ext/background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function onRequest(request, sender, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(data) {
if (xhr.readyState == 4) {
// xhr.status is 0, not 200. Weird. But, works. So, not checking it.
callback(xhr.responseText);
}
}

xhr.open('GET', request.url, true);
xhr.send();
};

chrome.extension.onRequest.addListener(onRequest);
</script>
</body>
</html>
20 changes: 10 additions & 10 deletions ext/dotjs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$.ajax({
url: 'http://localhost:3131/'+window.location.host.replace('www.','')+'.js',
dataType: 'text',
success: function(d){
$(function(){ eval(d) })
},
error: function(){
console.log('no dotjs server found at localhost:3131')
}
})
function apply(file) {
var pathToScript = chrome.extension.getURL("scripts/" + file);

console.log("dotjs fetching: " + pathToScript)
chrome.extension.sendRequest({'action': 'fetchScript', 'url': pathToScript},
function(script) { if (script != null && script != "") { eval(script); } });
}

apply("default.js");
apply(window.location.host + ".js");
1 change: 1 addition & 0 deletions ext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "~/.js",
"icons": { "48": "icon48.png",
"128": "icon128.png" },
"background_page" : "background.html",
"content_scripts": [{
"run_at": "document_start",
"matches": ["http://*/*", "https://*/*"],
Expand Down
Empty file added ext/scripts/default.js
Empty file.
60 changes: 60 additions & 0 deletions link_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<html>
<head>
<title>Symbolic link information for dotjs</title>
<style type="text/css">
.info { white-space: pre; opacity: 0.2; font-size: 0.5em; }
.show { opacity: 1; font-size: 1em; }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
function showInstructionsForOs() {
detect("Win", "windows");
detect("Mac", "mac");
detect("Linux", "linux");

}

function detect(osSubstring, idOfOSToShow) {
if (navigator.platform.indexOf(osSubstring) != -1) {
$("#" + idOfOSToShow).toggleClass("show");
$("#other").toggleClass("show");
}
}

window.onload = showInstructionsForOs;
</script>
</head>
<body>
<div id="mac" class="info">
It looks like you're using a Mac. Here's the location of the scripts directory for dotjs:
~/Library/Application Support/Google/Chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts

You can use the Terminal application to create a symbolic link to it using:
ln -s ~/Library/Application\ Support/Google/Chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts/ ~/.js
</div>

<div id="linux" class="info">
It looks like you're using Linux. Here's the location of the scripts directory for dotjs:
~/.config/google-chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts

You can use a terminal client to create a symbolic link to it using:
ln -s ~/.config/google-chrome/Default/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts/ ~/.js
</div>

<div id="windows" class="info">
It looks like you're using Windows. Here's the location of the scripts directory for dotjs:
C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Extensions\fcmioojcnohimpgepefmdndlejgghdni\1.3_3\scripts\

Please edit your dotjs scripts there.
</div>

<div id="other" class="info show">
Unable to find any information about your operating system. Use the link below to find the Chrome user data directory
on your system and go to:
USER-DATA-DIRECTORY/Extensions/fcmioojcnohimpgepefmdndlejgghdni/1.3_3/scripts/
</div>

<span class="info show">For more information, see <a href="http://www.chromium.org/user-experience/user-data-directory">this page</a></span>
</body>
</html>