Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @id tg-links@carb
- // @name IITC Carb: TG Links
- // @category Carb
- // @version 0.3.1.20160222.103152
- // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
- // @updateURL http://iitc.carbncl.com/plugins/carb.tg-links.meta.js
- // @downloadURL http://iitc.carbncl.com/plugins/carb.tg-links.user.js
- // @description [carb-2016-02-22-103152] Copies a portal link into the clipboard, for pasting into Telegram
- // @include https://www.ingress.com/intel*
- // @include http://www.ingress.com/intel*
- // @match https://www.ingress.com/intel*
- // @match http://www.ingress.com/intel*
- // @grant none
- // ==/UserScript==
- /* CHANGELOG
- - v0.1 First version
- - v0.2 Made the hypertext change between normal and clicked text
- - v0.2.1 Shortened the delay
- - v0.3 Added a guid query to PortalMapBot, changed plugin to match
- - v0.3.1 Removed the "guid" keyword from PortalMapBot queries
- */
- // PLUGIN START
- function wrapper(plugin_info) {
- // ensure plugin framework is there, even if iitc is not yet loaded
- if(typeof window.plugin !== 'function') window.plugin = function() {};
- //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
- //(leaving them in place might break the 'About IITC' page or break update checks)
- plugin_info.buildName = 'carb';
- plugin_info.dateTimeVersion = '20160222.103152';
- plugin_info.pluginId = 'carb.tglinks';
- //END PLUGIN AUTHORS NOTE
- // PLUGIN START
- // use own namespace for plugin
- window.plugin.tgLinks = function() {};
- window.plugin.tgLinks.normalText = 'TG Link';
- window.plugin.tgLinks.clickedText = 'TG Copied';
- window.plugin.tgLinks.delay = 1000;
- window.plugin.tgLinks.copyLink = function(guid) {
- var textArea = document.createElement('textarea');
- textArea.value = '@portalmapbot ' + guid;
- document.body.appendChild(textArea);
- textArea.select();
- try {
- document.execCommand('copy');
- $('#tg-links').html(window.plugin.tgLinks.clickedText);
- setTimeout(function() {
- $('#tg-links').html(window.plugin.tgLinks.normalText);
- }, window.plugin.tgLinks.delay);
- } catch (err) {
- console.log('TGLinks was unable to copy');
- }
- document.body.removeChild(textArea);
- };
- window.plugin.tgLinks.onPortalDetailsUpdated = function(data) {
- var onClick = 'window.plugin.tgLinks.copyLink(\'' + window.selectedPortal + '\')';
- var html = $('<div>').html( $('<a>').attr({id: 'tg-links', onclick: onClick, title: 'Copy a Telegram link to the clipboard'}).text(window.plugin.tgLinks.normalText) ).html();
- $('.linkdetails').append('<aside>' + html + '</aside>');
- };
- var setup = function() {
- addHook('portalDetailsUpdated', window.plugin.tgLinks.onPortalDetailsUpdated);
- };
- // PLUGIN END
- setup.info = plugin_info; //add the script info data to the function as a property
- if(!window.bootPlugins) window.bootPlugins = [];
- window.bootPlugins.push(setup);
- // if IITC has already booted, immediately run the 'setup' function
- if(window.iitcLoaded && typeof setup === 'function') setup();
- } // wrapper end
- // inject code into site context
- var script = document.createElement('script');
- var info = {};
- if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
- script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
- (document.body || document.head || document.documentElement).appendChild(script);
- // PLUGIN END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement