{"action":"created","issue":{"url":"https://api.github.com/repos/greasemonkey/greasemonkey/issues/2776","repository_url":"https://api.github.com/repos/greasemonkey/greasemonkey","labels_url":"https://api.github.com/repos/greasemonkey/greasemonkey/issues/2776/labels{/name}","comments_url":"https://api.github.com/repos/greasemonkey/greasemonkey/issues/2776/comments","events_url":"https://api.github.com/repos/greasemonkey/greasemonkey/issues/2776/events","html_url":"https://github.com/greasemonkey/greasemonkey/issues/2776","id":283786565,"number":2776,"title":"GM4 backward compatibility Issue","user":{"login":"erosman","id":6458876,"avatar_url":"https://avatars3.githubusercontent.com/u/6458876?v=4","gravatar_id":"","url":"https://api.github.com/users/erosman","html_url":"https://github.com/erosman","followers_url":"https://api.github.com/users/erosman/followers","following_url":"https://api.github.com/users/erosman/following{/other_user}","gists_url":"https://api.github.com/users/erosman/gists{/gist_id}","starred_url":"https://api.github.com/users/erosman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erosman/subscriptions","organizations_url":"https://api.github.com/users/erosman/orgs","repos_url":"https://api.github.com/users/erosman/repos","events_url":"https://api.github.com/users/erosman/events{/privacy}","received_events_url":"https://api.github.com/users/erosman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":42,"created_at":"2017-12-21T06:38:57Z","updated_at":"2017-12-29T14:16:33Z","closed_at":"2017-12-22T23:15:35Z","author_association":"NONE","body":"FF58 GM4.1\r\n\r\nI am preparing a backward Polyfill for GM3 (a Polyfill to make scripts written for GM4 to work on GM3) but I get into errors.\r\n\r\n\r\n```\r\nconsole.log(typeof GM);  // object\r\nconsole.log(typeof GM.openInTab);  // function\r\n```\r\n\r\nNext test ...\r\n\r\n```\r\nconsole.log(typeof GM);  // undefined\r\n\r\nif (typeof GM === 'undefined111') {\r\n  console.log('GM undefined called'); // no console log\r\n  var GM = {\r\n   // .. code\r\n  };\r\n}\r\n```\r\n\r\nAnother test ...\r\n\r\n```\r\nconsole.log(typeof GM);  // undefined\r\n\r\nif (typeof GM === 'undefined') {\r\n  console.log('GM undefined called'); // GM undefined called\r\n  var GM = {\r\n   // .. code\r\n  };\r\n}\r\n```\r\n\r\nWhat am I missing here?!\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/greasemonkey/greasemonkey/issues/comments/354451298","html_url":"https://github.com/greasemonkey/greasemonkey/issues/2776#issuecomment-354451298","issue_url":"https://api.github.com/repos/greasemonkey/greasemonkey/issues/2776","id":354451298,"user":{"login":"erosman","id":6458876,"avatar_url":"https://avatars3.githubusercontent.com/u/6458876?v=4","gravatar_id":"","url":"https://api.github.com/users/erosman","html_url":"https://github.com/erosman","followers_url":"https://api.github.com/users/erosman/followers","following_url":"https://api.github.com/users/erosman/following{/other_user}","gists_url":"https://api.github.com/users/erosman/gists{/gist_id}","starred_url":"https://api.github.com/users/erosman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erosman/subscriptions","organizations_url":"https://api.github.com/users/erosman/orgs","repos_url":"https://api.github.com/users/erosman/repos","events_url":"https://api.github.com/users/erosman/events{/privacy}","received_events_url":"https://api.github.com/users/erosman/received_events","type":"User","site_admin":false},"created_at":"2017-12-29T14:16:33Z","updated_at":"2017-12-29T14:16:33Z","author_association":"NONE","body":"> Why is @require undesired? Why copy and paste the same code into every script? What ever happened to \"reduce code duplication?\" \r\n\r\nI have my reasons which goes beyond the scope of this already long discussion. \r\n\r\n> It's not like the file is redownloaded every time it is run. \r\nTrue.. but it is downloaded once for every script, doesn't it?\r\n\r\n> I don't see the problem here. You're intentionally making this difficult for little benefit.\r\nIntentionally no... but that could be the case unintentionally.\r\n\r\nI started by wrriting my own code snnipet (hence the startin of this topic)\r\n\r\nAn example ...\r\n\r\n```\r\nif (typeof GM === 'undefined') {\r\n  var GM = {\r\n    'addStyle':             (...a) => GM_addStyle(...a),\r\n    'deleteValue':          (...a) => GM_deleteValue(...a),\r\n    'getResourceUrl':       (...a) => GM_getResourceURL(...a),\r\n    'getValue':             (...a) => GM_getValue(...a),\r\n    'listValues':           (...a) => GM_listValues(...a),\r\n    'notification':         (...a) => GM_notification(...a),\r\n    'openInTab':            (...a) => GM_openInTab(...a),\r\n    'registerMenuCommand':  (...a) => GM_registerMenuCommand(...a),\r\n    'setClipboard':         (...a) => GM_setClipboard(...a),\r\n    'setValue':             (...a) => GM_setValue(...a),\r\n    'xmlHttpRequest':       (...a) => GM_xmlhttpRequest(...a)\r\n  };\r\n}\r\n```\r\nNote: `gm4-polyfill.js` assigns all to the global GM and I was trying to assign GM to old functions without making it global.\r\n\r\n\r\nThen I run into trouble on GM4 with `var GM = `\r\nThat is when I posted this topic.\r\n\r\n`gm4-polyfill.js` achieves this by breaking the `'use strict'`. I wanted to do it without breaking  `'use strict'`\r\n\r\nThen we got sides-tracked into all sorts of issues and the topic became confusing.\r\n\r\n\r\n"}}
{"actor":{"display_login":"erosman"}}