Advertisement
tasuku

Untitled

Dec 8th, 2017
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Qt Blog Template
  3. // @namespace    http://qt.io/
  4. // @version      0.1
  5. // @description  この記事は〜を翻訳したものです。
  6. // @author       Tasuku Suzuki
  7. // @match        https://blog.qt.io/blog/*/*/*/*/
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     var title = $('h2.entry-title').text();
  15.     var url = location.href;
  16.     var author = $('div.author-avatar').next().children('a');
  17.     var name = author.text();
  18.     var link = author.attr('href');
  19.     var date = '';
  20.     if (/\/(20[0-9]{2})\/([0-9]{2})\/([0-9]{2})\//.test(location.pathname))
  21.         date = RegExp.$1 + '年' + RegExp.$2 + '月' + RegExp.$3 + '日';
  22.     var text = 'この記事は <a href="https://blog.qt.io/">The Qt Blog</a> の <a href="' + url + '">' + title + '</a> を翻訳したものです。\n';
  23.     text += '執筆: <a href="' + link + '">' + name + '</a>, ' + date;
  24.  
  25.  
  26.     $('h2.entry-title').before('<textarea rows="5" cols="80">' + text + '</textarea>');
  27. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement