Created
August 8, 2016 02:31
-
-
Save cr4m3r/58910181bd7c929b056a68f3044ed818 to your computer and use it in GitHub Desktop.
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 Zoltar - Autocopy Title | |
// @description sends page title to clipboard | |
// @description notifications and autoclose in chrome | |
// @author slothbear | |
// @version 2.0 | |
// @icon http://i.imgur.com/yptTSAh.gif | |
// @include http://* | |
// @include https://* | |
// @exclude https://www.mturk.com* | |
// @exclude http://www.mturkcrowd.com* | |
// @exclude http://www.mturkgrind.com* | |
// @exclude http://prolific.ac* | |
// @grant GM_setClipboard | |
// @grant GM_notification | |
// @grant window.close | |
// @require https://code.jquery.com/jquery-2.1.4.min.js | |
// ==/UserScript== | |
(function(){ | |
'use strict'; | |
//Copy Title or URL | |
var copyTitle = true; // set to false to copy URL | |
//VARIABLES TO SET | |
var firefox = false; // set to true if using firefox | |
// autoClose doesn't work in firefox | |
var autoClose = true; | |
var autoCloseTime = 15000; // how long before page close | |
if (copyTitle){ | |
copyTitleToClipboard(); | |
} else { | |
copyAddressToClipboard(); | |
} | |
chromeExtras(); | |
function copyTitleToClipboard(){ | |
//var title = window.top.document.title; | |
var title = window.parent.document.title; // should stop from multiple copies | |
GM_setClipboard(title); | |
} | |
function copyAddressToClipboard(){ | |
var address = location.href; | |
GM_setClipboard(address); | |
} | |
function chromeExtras(){ | |
if (!firefox){ | |
GM_notification(getNotificationDetails()); | |
autoCloser(); | |
} | |
} | |
function getNotificationDetails(){ | |
var notificationDetails={ | |
text: 'Zoltar!', | |
title: 'Site Title Copied.', | |
image: 'http://i.imgur.com/2rHdb2Q.gif', | |
timeout: 666 // is zoltar the devil? | |
}; | |
return notificationDetails; | |
} | |
function autoCloser(){ | |
if (autoClose){ | |
var winClose = "window.close()"; | |
setTimeout(winClose, autoCloseTime); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment