-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ibnishak
committed
Aug 16, 2018
1 parent
1812e9d
commit 30df98a
Showing
13 changed files
with
83 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Submodule chrome-chromium
added at
9e0a6a
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
function handleMessage(request, sender, sendResponse) { | ||
console.log("Sending native message"); | ||
browser.runtime.sendNativeMessage( | ||
"timimi", request); | ||
} | ||
|
||
|
||
browser.runtime.onMessage.addListener(handleMessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//var twport = browser.runtime.connect({ name: "port-from-cs" }); | ||
var idGenerator = 1; | ||
|
||
// Checking if the active tab is a local tiddlywiki file | ||
function checkTW() { | ||
var results = {}; | ||
// Test for TiddlyWiki Classic | ||
var versionArea = document.getElementById("versionArea"); | ||
results.isTiddlyWikiClassic = (document.location.protocol === "file:") && | ||
document.getElementById("storeArea") && | ||
(versionArea && /TiddlyWiki/.test(versionArea.textContent)); | ||
// Test for TiddlyWiki 5 | ||
var metaTags = document.getElementsByTagName("meta"); | ||
for (var t = 0; t < metaTags.length; t++) { | ||
if (metaTags[t].name === "application-name" && metaTags[t].content === "TiddlyWiki") { | ||
results.isTiddlyWiki5 = true; | ||
} | ||
} | ||
results.isTiddlyWiki = results.isTiddlyWikiClassic || results.isTiddlyWiki5; | ||
// Test for file URI | ||
if (document.location.protocol === "file:") { | ||
results.isLocalFile = true; | ||
} | ||
return results; | ||
} | ||
|
||
var checkTWResults = checkTW(); | ||
|
||
|
||
if (checkTWResults.isTiddlyWiki5 && checkTWResults.isLocalFile) { | ||
|
||
var messageBox = document.getElementById("tiddlyfox-message-box"); | ||
if (!messageBox) { | ||
messageBox = document.createElement("div"); | ||
messageBox.id = "tiddlyfox-message-box"; | ||
messageBox.style.display = "none"; | ||
document.body.appendChild(messageBox); | ||
} | ||
// Listen to initiate message from background script | ||
// Attach the event handler to the message box | ||
messageBox.addEventListener("tiddlyfox-save-file", onSaveTiddlyWiki, false); | ||
|
||
function onSaveTiddlyWiki(event) { | ||
// Get the details from the message | ||
var messageElement = event.target, | ||
path = messageElement.getAttribute("data-tiddlyfox-path"), | ||
content = messageElement.getAttribute("data-tiddlyfox-content"), | ||
backupPath = messageElement.getAttribute("data-tiddlyfox-backup-path"), | ||
messageId = "tiddlywiki-save-file-response-" + idGenerator++; | ||
// Send the details to background script. Not using port because we need a promise and port.postMessage is not a promise | ||
var sending = browser.runtime.sendMessage({ path: path, messageId: messageId, content: content, backupPath: backupPath }); | ||
sending.then(handleResponse, handleError); | ||
|
||
function handleResponse(message) { | ||
messageElement.parentNode.removeChild(messageElement); | ||
console.log("Saved successfully to " + path); | ||
console.log("Message ID is " + messageId); | ||
var event = document.createEvent("Events"); | ||
event.initEvent("tiddlyfox-have-saved-file", true, false); | ||
event.savedFilePath = path; | ||
messageElement.dispatchEvent(event); | ||
} | ||
|
||
function handleError() { | ||
console.log(`Error: ${error}`); | ||
} | ||
} | ||
|
||
} else { | ||
twport.disconnect(); | ||
} |
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
git clone --depth=1 https://github.com/ibnishak/Timimi.git | ||
cp -r Timimi/native-messaging-hosts $HOME/.mozilla | ||
cp -r Timimi/firefox/native-messaging-hosts $HOME/.mozilla | ||
sed -ie "s/richie/$USER/" $HOME/.mozilla/native-messaging-hosts/timimi.json | ||
cp Timimi/addons/web-ext-artifacts/timimi-1.3-an+fx.xpi $HOME | ||
cp Timimi/addons/web-ext-artifacts/timimi-1.3-an+fx.xpi $HOME |