Skip to content

Instantly share code, notes, and snippets.

@958
Last active December 24, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 958/6724744 to your computer and use it in GitHub Desktop.
Save 958/6724744 to your computer and use it in GitHub Desktop.
let PLUGIN_INFO =
<KeySnailPlugin>
<name>Speaker Deck</name>
<description>Manipulate Speaker Deck</description>
<updateURL>https://gist.github.com/958/6724744/raw/8ad2d8736534936917d525040693ba8736593b49/speakerdeck.ks.js</updateURL>
<version>0.0.1</version>
<author>958</author>
<license>MIT</license>
<minVersion>1.8.0</minVersion>
<detail><![CDATA[
===Usage===
With site-local-keymap.ks.js,
>|JavaScript|
local["^https?://speakerdeck.com/"] = [
['n', function () ext.exec("speakerdeck-next")],
['p', function () ext.exec("speakerdeck-previous")],
['f', function () ext.exec("speakerdeck-toggle-fullscreen")],
];
||<
]]></detail>
</KeySnailPlugin>;
var speakerDeck = (function() {
const NEXT = '.next';
const PREV = '.prev';
const FULL_SCREEN = '#fullscreen';
function execute(selector) {
if (content.document.location.host !== "speakerdeck.com")
return display.prettyPrint(M({
ja : "Speaker Deck のページではないようです",
en : "This page is not a part of Speaker Deck"
}));
try {
var win = content.document.querySelector('#slide') ?
content : content.document.querySelector('.speakerdeck-iframe').contentWindow;
if (win) {
var button = win.document.querySelector(selector);
if (button) button.click();
}
} catch(e) {
util.message(e);
}
}
return {
next: function() execute(NEXT),
prev: function() execute(PREV),
fullScreen: function() execute(FULL_SCREEN),
};
})();
plugins.withProvides(function (provide) {
provide("speakerdeck-next",
speakerDeck.next,
"Next page");
provide("speakerdeck-previous",
speakerDeck.prev,
"Previous page");
provide("speakerdeck-toggle-fullscreen",
speakerDeck.fullScreen,
"Toggle fullscreen status");
}, PLUGIN_INFO);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment