Last active
November 14, 2019 15:35
-
-
Save noromanba/f5bc6779c3c3005d6d106da5aa624990 to your computer and use it in GitHub Desktop.
append self-fork icon on Hatena::Let for UserScript
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
// ==UserScript== | |
// @name Hatena::Let self fork | |
// @namespace http://noromanba.flavors.me | |
// @description append self-fork icon on Hatena::Let for UserScript | |
// @include http://let.hatelabo.jp/* | |
// @grant none | |
// @noframes | |
// @run-at document-end | |
// @version 2017.3.2.0 | |
// @homepage https://gist.github.com/noromanba/f5bc6779c3c3005d6d106da5aa624990 | |
// @downloadURL https://gist.github.com/noromanba/f5bc6779c3c3005d6d106da5aa624990/raw/hatenalet-selffork.user.js | |
// @contributor taizooo http://let.hatelabo.jp/taizooo/let/gYC-ydPttrvedg | |
// @contributor noromanba http://let.hatelabo.jp/noromanba/let/gYC-x6_02LnWEg (Fork of) | |
// @license MIT License https://nrm.mit-license.org/2017 | |
// @author noromanba http://noromanba.flavors.me | |
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/BSicon_uetABZg%2B4.svg/128px-BSicon_uetABZg%2B4.svg.png | |
// ==/UserScript== | |
// Icon (PD by YLSS) | |
// https://commons.wikimedia.org/wiki/File%3ABSicon_uetABZg%2B4.svg | |
// Devel | |
// https://gist.github.com/noromanba/f5bc6779c3c3005d6d106da5aa624990 | |
// Bookmarklet | |
// http://let.hatelabo.jp/noromanba/let/gYC-x6_02LnWEg | |
(() => { | |
'use strict'; | |
const edit = document.body.querySelector('a.edit-link[href*="/let.edit"]'); | |
if (!edit) return; | |
// fork URL syntax | |
// http://let.hatelabo.jp/<USER_ID>/let.fork?code_id=<LET_ID> | |
// http://let.hatelabo.jp/<USER_ID>/let/<LET_ID> | |
// http://let.hatelabo.jp/<USER_ID>/let.fork?rev_id=<REV_ID> | |
// http://let.hatelabo.jp/<USER_ID>/let/<LET_ID>/rev/<REV_ID> | |
const fork = edit.cloneNode(); | |
fork.pathname = edit.pathname.replace(/\.edit$/, '.fork'); | |
fork.textContent = 'Fork'; | |
// TBD change image | |
edit.parentNode.appendChild(fork); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer works because the fork link has been replaced with a form that includes a
authenticity_token
field. I don't think there is any way around that from the browser.I now use https://github.com/defunkt/gist from the CLI to:
credential-helper
)original_url="git@gist.github.com:f5bc6779c3c3005d6d106da5aa624990.git"
url="$(date | gist -f temp)"
git clone $url; cd $(basename $url)
git remote add alt $original_url; git fetch alt
git reset --hard alt/master
git push -f origin master
Note: the
#
are in there so you can copy-pasta the whole block into the terminal 😉