Greasy Fork

Greasy Fork is available in English.

复制当前页面

复制当前页面标题及网址

当前为 2019-08-17 提交的版本,查看 最新版本

// ==UserScript==
// @name        复制当前页面
// @namespace   http://沉冰浮水.tk
// @description 复制当前页面标题及网址
// @include     http://*
// @include     https://*
// @version     1.6
// @grant       GM_registerMenuCommand
// @grant       GM_setClipboard
// jshint       esversion:6
// ==/UserScript==

(function () {
  'use strict';
  if (window.frames.length != parent.frames.length) {
    // alert('在iframe中');
    return false;
  }
  GM_registerMenuCommand('复制', () => {
    GM_setClipboard(document.title + '\n' + document.location.href);
    alert("复制成功:\r\n" + document.title + '\n' + document.location.href);
  });
  /* jshint multistr:true */

  function $n(e) {
    return document.querySelector(e);
  }
  function $na(e) {
    return document.querySelectorAll(e);
  }
})();